#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[10000];
long long ans[10000], sum[10000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  sum[0] = 0;
  for (int i = 0; i < (int)(n); i++) sum[i + 1] = sum[i] + a[i].first;
  ans[n] = 0;
  for (int i = (int)(n)-1; i >= 0; i--) {
    ans[i] = (long long)1000000000 * (long long)1000000000;
    for (int j = i + 1; j <= n; j++)
      ans[i] =
          min(ans[i], ans[j] + a[i].second + (sum[j - 1 + 1] - sum[i + 1]) -
                          a[i].first * (j - i - 1));
  }
  cout << ans[0];
  return 0;
}
