#include #include #include #define llint long long using namespace std; llint n; pair p[2005]; llint dp[2005][2005]; int main(void) { cin >> n; for(int i = 1; i <= n; i++) cin >> p[i].second >> p[i].first; sort(p+1, p+n+1); reverse(p+1, p+n+1); for(int i = 0; i <= n; i++){ for(int j = 0; j <= n; j++){ dp[i][j] = 1e18; } } dp[0][0] = 0; for(int i = 0; i < n; i++){ for(int j = 0; j <= n; j++){ dp[i+1][j] = min(dp[i+1][j], dp[i][j]); if(j+1 <= n) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + p[i+1].first*j + p[i+1].second); } } cout << dp[n][n-n/3] << endl; return 0; }