#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
void put1() { puts("YES"); }
void put2() { puts("NO"); }
void put3() { puts("-1"); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
using namespace std;
const int manx = 5e3 + 5;
struct node {
  long long x, w;
  friend bool operator<(node a, node b) { return a.x < b.x; }
} a[manx];
long long dp[manx][manx];
int main() {
  long long n = read();
  for (int i = 1; i <= n; i++) a[i].x = read(), a[i].w = read();
  sort(a + 1, a + 1 + n);
  a[0].x = -1e9, a[0].w = -1e9;
  for (int i = n; i >= 1; i--)
    for (int j = 0; j < i; j++)
      dp[i][j] = min(dp[i + 1][i] + a[i].w, dp[i + 1][j] + a[i].x - a[j].x);
  cout << dp[1][0] << endl;
  return 0;
}
