#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int L[5010], R[5010];
ll ret = LLONG_MAX;
ll dp[2][5010];
ll dp2[5010][5010];

int main() {
	cin >> N;
	rep(i, N) cin >> L[i] >> R[i];

	vector<pii> vec;

	rep(j, N) vec.eb(L[j]+R[j], j);
	sort(ALL(vec));

	for (int l=(N-1)/2; l <= (N/2); ++l) { // to left
		rep(j, N+1) rep(k, N+1) dp2[j][k] = LLONG_MAX;		
		dp2[N][0] = 0;
		
		for (int j = N-1; j >= 0; --j) {
			int id = vec[j].se;
			rep(k, N) {
				if (dp2[j+1][k] == LLONG_MAX) continue;
				dp2[j][k+1] = min(dp2[j][k+1], dp2[j+1][k] + (ll)k*(L[id]+R[id]) + R[id]);
				dp2[j][k] = min(dp2[j][k], dp2[j+1][k] + (ll)(N-1-j-k)*(L[id]+R[id]) + L[id]);					
			}			
		}

		int c = 0, f = 1;
		rep(j, 2) rep(k, N) dp[j][k] = LLONG_MAX;
		dp[0][0] = 0;

		rep(i, N) { //fix
			int id = vec[i].se;

			ll t = (ll)L[id] * l + (ll)R[id] * (N-1-l);

			ll u = LLONG_MAX;
			for (int p = 0; p <= l; ++p) {
				if (dp[c][p] == LLONG_MAX || dp2[i+1][l-p] == LLONG_MAX) continue;
				u = min(u, dp[c][p] + dp2[i+1][l-p]);
			}
			u += t;
			ret = min(ret, u);

			rep(j, N+1) dp[f][j] = LLONG_MAX;

			rep(k, N) {
				if (dp[c][k] == LLONG_MAX) continue;
				dp[f][k+1] = min(dp[f][k+1], dp[c][k] + (ll)(l-1-k)*(L[id]+R[id]) + R[id]);
				dp[f][k] = min(dp[f][k], dp[c][k] + (ll)((N-1-l)-1-(i-k))*(L[id]+R[id]) + L[id]);					
			}

			swap(c, f);
		}
	}

	cout << ret << endl;
	return 0;
}