#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

ll dp[5001][2];
ll cop[5001][2];
bool comp(LP a, LP b) {
	return a.second + a.first < b.second + b.first;
}
void solve() {
	int n; cin >> n;
	vector<LP> v(n);
	rep(i, n) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end(), comp);
	if (n % 2) {
		int d = n / 2;
		rep(i, d + 1) {
			rep(j, 2) {
				dp[i][j] = INF;
			}
		}
		dp[0][0] = 0;
		rep(i, n) {
			rep(j, d + 1) {
				rep(k, 2) {
					cop[j][k] = INF;
				}
			}
			ll len = v[i].second + v[i].first;
			rep(j, d + 1) {
				if (j > i)continue;
				//真ん中にする
				cop[j][1] = min(cop[j][1], dp[j][0] + d * len);
				//左にする
				if (j < d) {
					rep(k, 2) {
						cop[j + 1][k] = min(cop[j + 1][k], dp[j][k] + (d - 1 - j)*len + v[i].second);
					}
				}
				//右にする
				rep(k, 2) {
					int r = i - j - k;
					if (r < d) {
						cop[j][k] = min(cop[j][k], dp[j][k] + (d - 1 - r)*len + v[i].first);

					}
				}
			}
			rep(j, d + 1) {
				rep(k, 2) {
					dp[j][k] = cop[j][k];
				}
			}
		}
		ll ans = dp[d][1];
		cout << ans << endl;
	}
	else {
		ll ans = INF;

		int l = n / 2; int r = l - 1;
		rep(i, l + 1) {
			rep(j, 2) {
				dp[i][j] = INF;
			}
		}
		dp[0][0] = 0;
		rep(i, n) {
			rep(j, l + 1) {
				rep(k, 2) {
					cop[j][k] = INF;
				}
			}
			ll len = v[i].second + v[i].first;
			rep(j, l + 1) {
				if (j > i)continue;
				//真ん中にする
				cop[j][1] = min(cop[j][1], dp[j][0] + l * v[i].first + r*v[i].second);
				//左にする
				if (j < l) {
					rep(k, 2) {
						cop[j + 1][k] = min(cop[j + 1][k], dp[j][k] + (l - 1 - j)*len + v[i].second);
					}
				}
				//右にする
				rep(k, 2) {
					int rest = i - j - k;
					if (rest < r) {
						cop[j][k] = min(cop[j][k], dp[j][k] + (r - 1 - rest)*len + v[i].first);
					}
				}
			}
			//cout << i << endl;
			rep(j, l + 1) {
				rep(k, 2) {
					dp[j][k] = cop[j][k];
					//cout << j << " " << k << " " << dp[j][k] << endl;
				}
			}
		}
		ans = min(ans,dp[l][1]);

		//cout << ans << endl;
		l = n / 2-1; r = l+1;
		rep(i, l + 1) {
			rep(j, 2) {
				dp[i][j] = INF;
			}
		}
		dp[0][0] = 0;
		rep(i, n) {
			rep(j, l + 1) {
				rep(k, 2) {
					cop[j][k] = INF;
				}
			}
			ll len = v[i].second + v[i].first;
			rep(j, l + 1) {
				if (j > i)continue;
				//真ん中にする
				cop[j][1] = min(cop[j][1], dp[j][0] + l * v[i].first + r * v[i].second);
				//左にする
				if (j < l) {
					rep(k, 2) {
						cop[j + 1][k] = min(cop[j + 1][k], dp[j][k] + (l - 1 - j)*len + v[i].second);
					}
				}
				//右にする
				rep(k, 2) {
					int rest = i - j - k;
					if (rest < r) {
						cop[j][k] = min(cop[j][k], dp[j][k] + (r - 1 - rest)*len + v[i].first);
					}
				}
			}
			rep(j, l + 1) {
				rep(k, 2) {
					dp[j][k] = cop[j][k];
				}
			}
		}
		ans = min(ans, dp[l][1]);
		//cout << dp[l][1] << endl;
		cout << ans << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 384