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
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const lint INF=1e18;

int n;
pi range[5005];
lint dp[5005][5005];
int main(){
  cin>>n;
  REP(i,n) cin>>range[i].fr>>range[i].sc;
  sort(range,range+n,[&](pi a,pi b ){
    return a.fr+a.sc>b.fr+b.sc;
  });

  REP(i,5005) REP(j,5005) dp[i][j]=INF;

  int m=(n+1)/2;
  dp[0][0]=0;

  REP(i,m+1) REP(j,m+1) if(dp[i][j]<INF){
    pi r=range[i+j];
    lint sum=r.fr+r.sc;
    if(n&1 && i+1==m) chmin(dp[i+1][j],dp[i][j]+sum*i);
    else chmin(dp[i+1][j],dp[i][j]+sum*i+r.sc);
    if(n&1 && j+1==m) chmin(dp[i][j+1],dp[i][j]+sum*j);
    else chmin(dp[i][j+1],dp[i][j]+sum*j+r.fr);
  }
  lint res=INF;
  REP(i,m+1) REP(j,m+1) if(i+j==n) chmin(res,dp[i][j]);
  cout<<res<<endl;
  return 0;
}



