#include <bits/stdc++.h>
using namespace std;
long long myAbs(long long a) { return a > 0 ? a : -a; }
int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > input(N);
  vector<long long> dp(N, 1LL << 60);
  for (int i = 0; i < (int)(N); i++) {
    cin >> input[i].first >> input[i].second;
  }
  sort(input.begin(), input.end());
  long long tmp = 1LL << 60;
  long long res = 0;
  long long prePos = -1;
  for (int i = 0; i < (int)(N); i++) {
    long long cost = 0;
    if (i > 0) cost = dp[i - 1];
    cost += input[i].second;
    for (int j = i; j < N; j++) {
      cost += myAbs((long long)input[i].first - (long long)input[j].first);
      dp[j] = min(dp[j], cost);
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}
