#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[4000];
long long n, i, j, dp[4000], s[4000][4000];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; i++)
    for (j = i; j <= n; j++) s[i][j] = s[i][j - 1] + a[j].first - a[i].first;
  for (i = n; i > 0; i--) {
    dp[i] = 1e18;
    for (j = i; j <= n; j++)
      dp[i] = min(dp[i], dp[j + 1] + s[i][j] + a[i].second);
  }
  cout << dp[1] << endl;
}
