#include <bits/stdc++.h>
using namespace std;
long long rec(vector<vector<long long> > &dp,
              vector<pair<long long, long long> > &v, int i, int j) {
  if (i == v.size()) {
    return 0ll;
  }
  if (dp[i][j] != -1ll) {
    return dp[i][j];
  }
  long long ans = 1e18;
  long long x = v[i].first;
  long long c = v[i].second;
  long long xl = v[j].first;
  long long cl = v[j].second;
  long long z1 = rec(dp, v, i + 1, i);
  long long z2 = rec(dp, v, i + 1, j);
  if (z1 != 1e18) {
    ans = min(ans, z1 + c);
  }
  if (z2 != 1e18) {
    ans = min(ans, z2 + abs(x - xl));
  }
  dp[i][j] = ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  vector<vector<long long> > dp(n, vector<long long>(n, -1));
  long long ans = rec(dp, v, 1, 0) + v[0].second;
  cout << ans << endl;
}
