import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long[][] A = new long[N][2]; for (int i = 0; i < N; ++i) { A[i][0] = sc.nextLong(); A[i][1] = sc.nextLong(); } Arrays.sort(A, new Comparator() { @Override public int compare(long[] o1, long[] o2) { return -Long.compare(o1[1], o2[1]); } }); long[][] dp = new long[N + 1][N + 1]; for (int i = 0; i < dp.length; ++i) for (int j = 0; j < dp[i].length; ++j) dp[i][j] = Long.MAX_VALUE / 3; dp[0][0] = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j <= N; ++j) { if (j + 1 <= N) dp[i + 1][j + 1] = Math.min(dp[i + 1][j + 1], dp[i][j] + A[i][0] + A[i][1] * j); dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]); } } int sub = 0; for (int i = 0, res = N; res > 0; ++i) { --res; if (i % 2 == 1 && res > 0) { --res; ++sub; } } System.out.println(dp[N][N - sub]); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }