#include using namespace std; int main() { int n; cin >> n; vector> v; for (int i = 0; i < n; i++) { long long a, b; cin >> a >> b; v.emplace_back(b, a); } sort(v.rbegin(), v.rend()); vector> dp(n+1, vector(n+1, 1e12)); dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { // dp[i][j] dp[i+1][j] = min(dp[i+1][j], dp[i][j]+v[i].second+v[i].first*(i-j)); dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]); } } cout << dp[n][n/3] << endl; return 0; }