#include <bits/stdc++.h>
using namespace std;
long long int n, INF = 1e14;
vector<pair<long long int, long long int> > arr(5005);
long long int sum[5005], dp[5005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second;
  sort(arr.begin() + 1, arr.begin() + n + 1);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + arr[i].first;
  dp[1] = arr[1].second;
  for (int i = 2; i <= n; i++) {
    dp[i] = INF;
    for (int j = 1; j <= i; j++) {
      if (j == i)
        dp[i] = min(dp[i], dp[i - 1] + arr[i].second);
      else {
        long long int pos = arr[j].first, num = i - j;
        long long int x = sum[i] - sum[j];
        dp[i] = min(dp[i], abs(x - pos * num) + arr[j].second + dp[j - 1]);
      }
    }
  }
  cout << dp[n];
  return 0;
}
