#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int N = 3005;
long long int S[N], dp[N], LS[N], acm[N];
long long int foo[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ;
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > v;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    long long int x, c;
    cin >> x >> c;
    v.push_back({x, c});
  }
  sort((v).begin(), (v).end());
  foo[0] = v[0].first;
  for (long long int i = (long long int)(1); i < (long long int)((v).size());
       i++)
    foo[i] = foo[i - 1] + v[i].first;
  for (int i = (v).size() - 1; i >= 0; i--) acm[i] = acm[i + 1] + v[i].first;
  for (int i = (v).size() - 1; i >= 0; i--)
    S[i] = acm[i + 1] - v[i].first * (((v).size() - 1) - i);
  dp[0] = S[0] + v[0].second, LS[0] = 0;
  for (long long int i = (long long int)(1); i < (long long int)((v).size());
       i++) {
    dp[i] = dp[i - 1], LS[i] = LS[i - 1];
    for (int j = i; j >= 0; j--) {
      long long int cal = dp[j] - S[LS[j]] + S[i] + (foo[i - 1] - foo[LS[j]]) -
                          v[LS[j]].first * (i - LS[j] - 1) + v[i].second;
      if (cal < dp[i]) dp[i] = cal, LS[i] = i;
    }
  }
  cout << dp[(v).size() - 1] << endl;
  return 0;
}
