import java.io.*;
import java.util.*;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;

public class conquest_ag_wa extends PrintWriter {
    BufferedReader br;
    StringTokenizer stok;
    final Random rand = new Random(31);
    final int inf = (int) 1e9;
    final long linf = (long) 1e18;

    class Item {
        int a, c;

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

    void solve() throws IOException {
        int n = nextInt();
        Item[] a = new Item[n + 1];
        int sum = 0;
        int max = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = new Item(nextInt(), nextInt());
            sum += a[i].a;
            max = max(max, a[i].a);
        }
        Arrays.sort(a, 1, n, (i1, i2) -> i1.a == i2.a ? i1.c - i2.c : i1.a - i2.a);
        long[][] d = new long[n + 1][max + 1];
        int partSum = 0;
        for (int i = 1; i <= n; i++) {
            Item cur = a[i];
            for (int j = 0; j <= max; j++) {
                d[i][j] = linf;
                for (int k = 0; k <= cur.a; k++) {
                    if (partSum + j + k > cur.a - k) {
                        d[i][j] = min(d[i][j], d[i - 1][min(max, j + k)] + k * cur.c);
                    }
                }
            }
            partSum += cur.a;
        }
        println(d[n][0]);
    }

    void run() throws IOException {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignore) {
        }
        new conquest_ag_wa("conquest").run();
    }

    conquest_ag_wa() {
        super(System.out);
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    conquest_ag_wa(String s) throws FileNotFoundException {
        super("".equals(s) ? "output.txt" : s + ".out");
        br = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : s + ".in"));
    }

    String next() {
        try {
            while (stok == null || !stok.hasMoreTokens()) {
                stok = new StringTokenizer(br.readLine());
            }
        } catch (IOException e) {
            return null;
        }
        return stok.nextToken();
    }

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

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

    double nextDouble() {
        return Double.parseDouble(next());
    }

    int[] nextIntArray(int len) {
        int[] res = new int[len];
        for (int i = 0; i < len; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    void shuffle(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int x = rand.nextInt(i + 1);
            int t = a[i];
            a[i] = a[x];
            a[x] = t;
        }
    }

    boolean nextPerm(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        return false;
    }

    <T> List<T>[] genAdjacencyList(int countVertex) {
        List<T>[] res = new List[countVertex];
        for (int i = 0; i < countVertex; i++) {
            res[i] = new ArrayList<T>();
        }
        return res;
    }
}