Snuke received N intervals as a birthday present. The i-th interval was [-L_i, R_i]. It is guaranteed that both L_i and R_i are positive. In other words, the origin is strictly inside each interval.

Snuke doesn't like overlapping intervals, so he decided to move some intervals. For any positive integer d, if he pays d dollars, he can choose one of the intervals and move it by the distance of d. That is, if the chosen segment is [a, b], he can change it to either [a+d, b+d] or [a-d, b-d].

He can repeat this type of operation arbitrary number of times. After the operations, the intervals must be pairwise disjoint (however, they may touch at a point). Formally, for any two intervals, the length of the intersection must be zero.

Compute the minimum cost required to achieve his goal.

Constraints

* 1 ≤ N ≤ 5000
* 1 ≤ L_i, R_i ≤ 10^9
* All values in the input are integers.

Input

The input is given from Standard Input in the following format:


N
L_1 R_1
:
L_N R_N


Output

Print the minimum cost required to achieve his goal.

Examples

Input

4
2 7
2 5
4 1
7 5


Output

22


Input

20
97 2
75 25
82 84
17 56
32 2
28 37
57 39
18 11
79 6
40 68
68 16
40 63
93 49
91 10
55 68
31 80
57 18
34 28
76 55
21 80


Output

7337
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 62;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
pl I[5010];
ll dp[2510][2510][2];

bool compare(const pl& p1, const pl& p2) {
	return (p1.sec + p1.fst) > (p2.sec + p2.fst);
}

void solve() {
	cin >> N;
	rep(i, 0, N) {
		ll l, r;
		cin >> l >> r;
		I[i] = pl(l, r);
	}
	sort(I, I + N, compare);

	int LN = (N - 1) / 2, RN = N / 2;

	rep(i, 0, LN + 1) {
		rep(j, 0, RN + 1) {
			dp[i][j][0] = linf;
			dp[i][j][1] = linf;
		}
	}

	dp[0][0][0] = 0;

	rep(i, 0, LN + 1) {
		rep(j, 0, RN + 1) {
			rep(k, 0, 2) {
				if(dp[i][j][k] == linf) continue;
				int id = i + j + k;
				ll l = I[id].fst, r = I[id].sec;
				if(i < LN) MIN(dp[i + 1][j][k], dp[i][j][k] + (l + r) * (i + 1) - l);
				if(j < RN) MIN(dp[i][j + 1][k], dp[i][j][k] + (l + r) * (j + 1) - r);
				if(k == 0) MIN(dp[i][j][k + 1], dp[i][j][k] + l * LN + r * RN);
			}
		}
	}
	cout << dp[LN][RN][1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

