#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   void solve() {     int n;     cin >> n;     vector<pair<int, int>> data(n);     for (auto &x : data) cin >> x.first >> x.second;     sort(data.begin(), data.end());     vector<vector<long long>> dp(2, vector<long long>(n, 0));     dp[0][0] = LLONG_MAX;     dp[1][0] = data[0].second;     for (int curr = 1; curr < n; curr++) {       dp[1][curr] = data[curr].second + min(dp[0][curr - 1], dp[1][curr - 1]);       dp[0][curr] = LLONG_MAX;       long long sum = 0;       int cnt = 1;       for (int prev = curr - 1; prev >= 0; prev--) {         sum += 1ll * (data[prev + 1].first - data[prev].first) * cnt;         if (sum + dp[1][prev] < dp[0][curr]) dp[0][curr] = sum + dp[1][prev];         ;         cnt++;       }     }     cout << min(dp[0][n - 1], dp[1][n - 1]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     solve();     return 0;   }   