#include using namespace std; template istream& operator>>(istream& is, pair& a){ return is >> a.first >> a.second; } template ostream& operator<<(ostream& os, pair& a){ return os << a.first << " "< istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; } template ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; } #define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++) #define ALL(v) (v).begin(), (v).end() #define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());} #define fr first #define sc second typedef pair< int , int > Pi; typedef pair< int , Pi > Pii; typedef long long int64; const int INF = 1 << 30; int main() { int N; Pi Data[10000]; vector< bool > dp(20001, false); cin >> N; for(int i = 0; i < N; i++){ cin >> Data[i].first >> Data[i].second; } sort( Data, Data + N); dp[0] = true; for(int i = 0; i < N; i++){ for(int j = Data[i].second - 1; j >= 0; j--){ dp[j + Data[i].first] = dp[j + Data[i].first] | dp[j]; } } int ret = 0; for(int i = 20000; i >= 0; i--){ ret = max( ret, i * dp[i]); } cout << ret << endl; return(0); }