During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two numbers — a_i and b_i. Dissatisfaction of the person i equals the product of a_i by the number of people standing to the left of his position, add the product b_i by the number of people standing to the right of his position. Formally, the dissatisfaction of the student i, which is on the position j, equals a_i ⋅ (j-1) + b_i ⋅ (n-j).

The director entrusted Stas with the task: rearrange the people in the queue so that minimize the total dissatisfaction.

Although Stas is able to solve such problems, this was not given to him. He turned for help to you.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of people in the queue.

Each of the following n lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ 10^8) — the characteristic of the student i, initially on the position i.

Output

Output one integer — minimum total dissatisfaction which can be achieved by rearranging people in the queue.

Examples

Input


3
4 2
2 3
6 1


Output


12

Input


4
2 4
3 3
7 1
2 3


Output


25

Input


10
5 10
12 4
31 45
20 55
30 17
29 30
41 32
7 1
5 5
3 15


Output


1423

Note

In the first example it is optimal to put people in this order: (3, 1, 2). The first person is in the position of 2, then his dissatisfaction will be equal to 4 ⋅ 1+2 ⋅ 1=6. The second person is in the position of 3, his dissatisfaction will be equal to 2 ⋅ 2+3 ⋅ 0=4. The third person is in the position of 1, his dissatisfaction will be equal to 6 ⋅ 0+1 ⋅ 2=2. The total dissatisfaction will be 12.

In the second example, you need to put people in this order: (3, 2, 4, 1). The total dissatisfaction will be 25.

//package sept;

import java.io.*;
import java.util.*;

public class TimePass implements Runnable {
    InputStream is;
    PrintWriter out;
    String INPUT = "";
    //boolean debug=false;
    boolean debug=true;
    static long mod=998244353;
    static long mod2=1000000007;
    
    void solve() throws IOException
	{
	    
	    int n=ni();
	    Pair[] a=new Pair[n];
	    long ans=0;
	    for(int i=0;i<n;i++)
	    {
	        a[i]=new Pair(ni(),ni());
	        a[i].c=a[i].a-a[i].b;
	        ans+=((long)(n-1)*a[i].b);
	    }
	    Arrays.sort(a,new Comparator<Pair>(){
	        public int compare(Pair p1,Pair p2)
	        {
	            return p2.c-p1.c;
	        }
	    });
	    for(int i=0;i<n;i++)
	    {
	        //out.println(a[i].c);
	        ans+=(long)i*a[i].c;
	    }
	    out.println(ans);
	    /*
	    ArrayList<Long> list=new ArrayList<>();
	    for(long i=1;i<=(long)2e18;i*=2)
	    {
	        list.add(i);
	    }
	    long l=nl(),r=nl();
	    out.println((sum(r,list)-sum(l-1,list)+mod2)%mod2);
	    */
	}
	
	long sum(long v,ArrayList<Long> list)
	{
	    long curr=v;
	    int cnt=0;
	    while(curr>0)
	    {
	        curr/=2;
	        cnt++;
	    }
	    int ind=Collections.binarySearch(list,v);
	    if(ind<0)ind=-ind-2;
	    if(ind<0)return 0;
	    
	    long extra=v-list.get(ind)+1;
	    //out.println(list.get(ind)+" "+extra);
	    long totcurr=((long)1<<cnt)/2;
	    //out.println(totcurr);
	    int f=0;
	    long odd=0,even=0;
	    for(long i=1;i<totcurr;i*=2)
	    {
	        if(f==0)odd+=i;
	        else even+=i;
	        //if(even<0 || odd<0)return -1;
	        f^=1;
	    }
	    if(cnt%2==0)even+=extra;
	    else odd+=extra;
	    //out.println(odd+" "+even+" "+extra);
	    return (cont(even,2,2)%mod2+cont(odd,1,2)%mod2)%mod2;
	}
	
	long cont(long n,long a,long d)
	{
	    n%=mod2;
	    return (((n*(2*a+((n-1)%mod2*d%mod2)%mod2)%mod2)%mod2)%mod2*inv(2,(int)mod2))%mod2;
	}
	
    static long comp(ArrayList<Integer> l,long k)
    {
    	int curr=0;
    	int sz=l.size();
    	while(curr<sz && l.get(curr)==-1)curr++;
    	if(curr==sz)
    	{
    		return (pow((int)k-1,sz-1,(int)mod)*k)%mod;
    	}
    	long ans=pow((int)k-1,curr,(int)mod);
    	int prev=curr;
    	curr++;
    	while(curr<sz)
    	{
    		if(l.get(curr)!=-1)
    		{
    			ans=(ans*ways(curr-prev+1,k,l.get(curr)==l.get(prev)))%mod;
    			prev=curr;
    		}
    		curr++;
    	}
    	curr=curr-prev-1;
    	if(curr>=0)ans=(ans*pow((int)k-1,curr,(int)mod))%mod;
    	return ans;
    }
    
    static long[][] dp;
    
    private static long ways(int n, long k, boolean b) {
		// TODO Auto-generated method stub
    	
    	if(b)
    	{
    	    dp[0][0]=1;
    	    dp[0][1]=0;
    		dp[1][0]=0;
    		dp[1][1]=k-1;
    	}
    	else 
    	{
    	    dp[0][0]=0;
    	    dp[0][1]=0;
    		dp[1][0]=1;
    		dp[1][1]=k-2;
    	}
    	for(int i=2;i<n;i++)
    	{
    		dp[i][0]=dp[i-1][1];
    		dp[i][1]=(dp[i-1][0]*(k-1)+dp[i-1][1]*(k-2))%mod;
    	}
		return dp[n-1][0];
	}

	static Pair[][] packU(int n,int[] from,Pair[] to)
	{
		Pair[][] g=new Pair[n][];
		int[] p=new int[n];
		for(int f:from)
		{
			p[f]++;
		}
		int m=from.length;
		for(int i=0;i<n;i++)
		{
			g[i]=new Pair[p[i]];
		}
		for(int i=0;i<m;i++)
		{
			g[from[i]][--p[from[i]]]=to[i];
		}
		return g;
	}
    
	static int[][] packD(int n,int[] from,int[] to)
	{
		int[][] g=new int[n][];
		int[] p=new int[n];
		for(int f:from)
		{
			p[f]++;
		}
		int m=from.length;
		for(int i=0;i<n;i++)
		{
			g[i]=new int[p[i]];
		}
		for(int i=0;i<m;i++)
		{
			g[from[i]][--p[from[i]]]=to[i];
		}
		return g;
	}
	    
    static class Pair
    {
        int a,b,c;
        public Pair(int a,int b)
        {
            this.a=a;
            this.b=b;
            //this.ind=ind;
        }
    }
    
    static long lcm(int a,int b)
    {
        long val=a;
        val*=b;
        return (val/gcd(a,b));
    }
    
    static long gcd(long a,long b)
    {
        if(a==0)return b;
        return gcd(b%a,a);
    }
    
    static int pow(int a, int b, int p)
    {
        long ans = 1, base = a;
        while (b!=0)
        {
            if ((b & 1)!=0)
            {
                ans *= base;
                ans%= p;
            }
            base *= base;
            base%= p;
            b >>= 1;
        }
        return (int)ans;
    }

    static int inv(int x, int p)
    {
        return pow(x, p - 2, p);
    }
    
    public static long[] radixSort(long[] f){ return radixSort(f, f.length); }
	public static long[] radixSort(long[] f, int n)
	{
		long[] to = new long[n];
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(int)(f[i]&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[(int)(f[i]&0xffff)]++] = f[i];
			long[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>16&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>16&0xffff)]++] = f[i];
			long[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>32&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>32&0xffff)]++] = f[i];
			long[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(int)(f[i]>>>48&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[(int)(f[i]>>>48&0xffff)]++] = f[i];
			long[] d = f; f = to;to = d;
		}
		return f;
	}
    
    public void run()
    {
        if(debug)oj=true;
        is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);
        
        long s = System.currentTimeMillis();
        try {
			solve();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        out.flush();
        tr(System.currentTimeMillis()-s+"ms");
    }
    
    public static void main(String[] args) throws Exception {new Thread(null,new TimePass(),"Main",1<<26).start();}
    
    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;
    
    private int readByte()
    {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }
    
    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
    
    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }
    
    private String ns()
    {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    private char[] ns(int n)
    {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }
    
    private char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }
    
    private int[] na(int n)
    {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }
    
    private int ni()
    {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        
        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
    
    private long nl()
    {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        
        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
    
    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
