import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class conquest_as_wa1 {
    class City {
        int a;
        int c;

        City(int a, int c) {
            this.a = a;
            this.c = c;
        }
    }

    final static int INF = Integer.MAX_VALUE;

    public void run() throws IOException {
        in = new FastScanner(new FileInputStream("conquest.in"));
        out = new PrintWriter(new FileOutputStream("conquest.out"));

        int n = in.nextInt();
        City[] c = new City[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            c[i] = new City(in.nextInt(), in.nextInt());
            total += c[i].a;
        }
        Arrays.sort(c, (x, y) -> x.a - y.a);

        int[] sum = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sum[i + 1] = sum[i] + c[i].a;
        }

        int[][] d = new int[n + 1][total + 1];
        for (int[] z : d) {
            Arrays.fill(z, INF);
        }
        Arrays.fill(d[0], 0);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < total; j++) {
                if (d[i][j] != INF) {
                    for (int k = 0; k <= c[i].a && k <= j; k++) {
                        int cost = k * c[i].c;
                        int count = sum[i] + j;
                        if (count > c[i].a - k && d[i][j] + cost < d[i + 1][j - k]) {
                            d[i + 1][j - k] = d[i][j] + cost;
                        }
                    }
                }
            }
        }

        out.println(d[n][0]);

        out.close();
    }

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new conquest_as_wa1().run();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}