#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef pair pll; typedef vector vi; typedef vector vl; typedef long double ld; int n; const int MAXN = 101; ll big = 1000000007; vl F,T,ind; unordered_map DP; bool comp(int i, int j){ return T[i] < T[j]; } ll dp(int i, int free){ if(i < 0)return 0; int h = i * 1000 * 1000 + free; if(DP.find(h) != DP.end())return DP[h]; ll ans = big*big; int j = ind[i]; rep(new_free,0,F[j]+1){ int rm = F[j]-new_free; if(rm <= free){ ll temp = new_free * T[j] + dp(i-1, free-rm+new_free); ans = min(ans, temp); } } DP[h] = ans; return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; rep(c1,0,n){ int f,t; cin >> f >> t; F.push_back(f); T.push_back(t); ind.push_back(c1); } sort(all(ind), comp); cout << dp(n-1,0) << "\n"; return 0; }