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 <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 2505, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

ll dp[MX][MX][2];

int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  rep(i,n) scanf("%d%d",&a[i],&b[i]);
  vi id(n);
  rep(i,n) id[i] = i;
  sort(rng(id),[&](int i, int j) { return a[i]+b[i] > a[j]+b[j];});
  int m = n/2;
  rep(i,m+1)rep(j,m+1)rep(k,2) dp[i][j][k] = LINF;
  dp[0][0][0] = 0;
  rep(i,n) {
    ll x = a[id[i]];
    ll y = b[id[i]];
    ll w = x+y;
    rep(k,2)rep(l,m+1) {
      int r = i-k-l;
      if (r < 0) break;
      if (!k) {
        mins(dp[l][r][k+1], dp[l][r][k]+w*m);
      }
      mins(dp[l+1][r][k], dp[l][r][k]+w*l+y);
      mins(dp[l][r+1][k], dp[l][r][k]+w*r+x);
    }
  }
  cout<<dp[m][m][n&1]<<endl;
  return 0;
}





























