#include <bits/stdc++.h>
using namespace std;
struct name {
  long long x, c;
};
bool operator<(name A, name B) { return A.x < B.x; };
name a[500000];
long long sumtoi[500000];
long long ans[500000];
long long n, i, last, res;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i].x >> a[i].c;
  sort(a + 1, a + n + 1);
  for (i = n - 1; i >= 1; i--)
    sumtoi[i] = sumtoi[i + 1] + (a[i + 1].x - a[i].x) * (n - i);
  ans[1] = a[1].c + sumtoi[1];
  res = ans[1];
  for (i = 2; i <= n; i++) ans[i] = 500000000000LL;
  for (i = 2; i <= n; i++)
    for (last = 1; last < i; last++)
      if (ans[i] > ans[last] - (n - i + 1) * (a[i].x - a[last].x) + a[i].c)
        ans[i] = ans[last] - (n - i + 1) * (a[i].x - a[last].x) + a[i].c;
  for (i = 1; i <= n; i++) res = min(res, ans[i]);
  cout << res << endl;
}
