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.
    import javax.print.DocFlavor;
    import java.io.*;
    import java.math.BigInteger;
    import java.util.*;
    import java.util.LinkedList;
    import java.util.regex.*;


    public class Main {
        static BigInteger[] dp = new BigInteger[10000];

        static BigInteger fib(int n) {
            n -= 1;
            if (n <= 1) return BigInteger.ONE;
            if (dp[n] != null) return dp[n];
            dp[0] = BigInteger.ONE;
            dp[1] = BigInteger.ONE;
            dp[n] = dp[n-1].add(dp[n-2]);
            return dp[n];
        }
        static long solve(int n) {
            if(n<=2) return n*2;
            long [] dp = new long[n];
            dp[0] = 2;
            dp[1] = 4;
            dp[2] = 7;
            int numberOfWhite = 1;
            for (int i = 3; i < n; i++) {
                dp[i] = (dp[i-1]-numberOfWhite)*2 + 1;
                numberOfWhite*=2;
            }
            return dp[n-1];
        }
        private static int convert(int first, int second) {
            int k = 1;
            int equation = second-first+k*26;
            while(equation<97) {
                k++;
                equation = second-first+k*26;
            }
            return equation;
        }

        private static boolean check(int n) {
            return n>=97 && n<=122;
        }
        public static void main(String[] args) throws IOException {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

            int n = in.nextInt();
            long[][] ar = new long[n][2];
            for (int i = 0; i < n; i++) {
                ar[i][0] = in.nextLong();
                ar[i][1] = in.nextLong();
            }
            Arrays.sort(ar, (x,y)->Long.compare(x[1]-x[0],y[1]-y[0]));
            long sum = 0;
            for (int i = 0; i < ar.length; i++) {
                sum+=ar[i][0]*i+ar[i][1]*(n-1-i);
            }
            out.println(sum);

            out.flush();
        }
        private static boolean isValid(String s) {
            char [] c = s.toCharArray();
            Stack<Character> stack = new Stack<>();
            for (int i = 0; i < c.length; i++) {
                if(c[i] == '(') stack.push(c[i]);
                else {
                    if(stack.empty()) continue;
                    stack.pop();
                }
            }
            return stack.empty();
        }
        private static int solve(int s, int d, int t) {
            int x = t-s;
            if(x%d==0) return x/d;
            return x/d+1;
        }
        private static int solve(String [] a) {
            HashSet<String> set = new HashSet<>();
            for (int i = 0; i < a.length; i++) {
                for (int j = 0; j < a.length; j++) {
                    if(i!=j) {
                        String rhyme = isRhyme(a[i],a[j]);
                        if(rhyme!=null) {
                            if(!isAlready(set,a[i],rhyme) && !isAlready(set,a[j],rhyme)) {
                                set.add(a[i]);
                                set.add(a[j]);
                            }
                        }
                    }
                }
            }
            System.out.println(set);
            return set.size();
        }
        private static boolean isAlready(HashSet<String> set, String s, String rhyme) {
            if(set.size() == 0) return false;
            Iterator<String> it = set.iterator();
            boolean flag = false;
            while (it.hasNext()) {
                String current = it.next();
                String rTemp = isRhyme(current,s);
                if(rTemp!=null) {
                    if(!rTemp.equals(rhyme)) return false;
                    else flag = true;
                }
            }
            return flag;
        }
        private static String isRhyme(String a, String b) {
            char [] ca = a.toCharArray();
            for (int i = 0; i < ca.length; i++) {
                int index = b.indexOf(ca[i]);
                if(index>=0) {
                    String tempa = a.substring(i);
                    String tempb = b.substring(index);
                    if(tempa.equals(tempb)) return tempa;
                }
            }
            return null;
        }
        private static String reverseTheString(String s) {
            char [] c = s.toCharArray();
            int i = 0;
            int j = c.length - 1;
            while(i<j) {
                char temp = c[i];
                c[i] = c[j];
                c[j] = temp;
                i++;
                j--;
            }
            return new String(c);
        }
        private  static  StringBuilder convertToString(int value) {
            char c = (char)(value + 'a');
            String temp = Character.toString(c);
            return new StringBuilder(temp);
        }
        private static String anotherPath(String s) {
            char [] c = s.toCharArray();
            char [] newS = new char[c.length];
            for (int i = 0; i < c.length; i++) {
                if(c[i]=='E') {
                    newS[i] = 'S';
                }
                else {
                    newS[i] = 'E';
                }
            }
            return new String(newS);
        }
        private static String newPath(String s, int l) {
            char [] c = s.toCharArray();
            StringBuilder sb = new StringBuilder();
            // check for SS...EE..
            // check for EE..SS..
            char first = c[0];
            char last = c[c.length - 1];
            if(first!=last) {
                // he comes from top
                if(last == 'S') {
                    for (int i = 0; i < l-1; i++) {
                        sb.append("S");
                    }
                    for (int i = 0; i < l-1; i++) {
                        sb.append("E");
                    }
                }
                else {
                    for (int i = 0; i < l-1; i++) {
                        sb.append("E");
                    }
                    for (int i = 0; i < l-1; i++) {
                        sb.append("S");
                    }
                }
            }
            else {
                // begins and ends with E
                if(first == 'E') {
                    sb.append("S");
                    for (int i = 0; i < l-1; i++) {
                        sb.append("E");
                    }
                    for (int i = 0; i < l-2; i++) {
                        sb.append("S");
                    }
                }
                else {
                    sb.append("E");
                    for (int i = 0; i < l-1; i++) {
                        sb.append("S");
                    }
                    for (int i = 0; i < l-2; i++) {
                        sb.append("E");
                    }
                }
            }


            return sb.toString();
        }
        private static boolean isSSEEorEESS(char [] c) {
            char first = c[0];
            int count = 1;
            for (int i = 1; i < c.length; i++) {
                if(c[i]==first) {
                    count++;
                }
                else {
                    break;
                }
            }
            return  (count<c.length/2);
        }
        private static void fillVisited(String  s, boolean [][] visited) {
            char [] c = s.toCharArray();
            int i=0,j=0;
            visited[i][j] = true;
            for (int k = 0; k < c.length; k++) {
                if(c[k]=='E') {
                    visited[i][++j] = true;
                }
                else {
                    visited[++i][j] = true;
                }
            }
        }

        private static boolean isTheSame(char [] c) {
            Arrays.sort(c);
            for (int i = 0; i < c.length - 1; i++) {
                if(c[i+1] - c[i]!=1) return false;
            }
            return true;
        }
        private static int solveToCheck(int n) {
            int max= Integer.MIN_VALUE;
            int number = 1;
            for (int i = 1; i <=n; i++) {
                if(product(i) > max) {
                    max = product(i);
                    number = i;
                }
            }
            return max;
        }
        private static int product(int n) {
            int p = 1;
            while (n>0) {
                p*=n%10;
                n/=10;
            }
            return p;
        }
        private static void reverseTheString(char [] s, int i, int j) {
            if(i == j) return;
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
            i++;
            j--;
            reverseTheString(s,i,j);
        }
        public static String reverseString(String str){

            if(str.isEmpty()){
                return str;
            } else {
                System.out.println(str.substring(1) + str.charAt(0));
                return reverseString(str.substring(1))+str.charAt(0);
            }
        }

        private static void shuffleAnArray(int [] a) {
            for (int i = 0; i < a.length; i++) {
                int index = (int)Math.random()*a.length;
                int temp = a[i];
                a[i] = a[index];
                a[index] = temp;
            }
        }
        public static List<String> commonChars(String[] A) {
            int [][] freqs = new int[A.length][26];
            for(int i=0;i<freqs.length;i++) {
                freqs[i] = freq(A[i]);
            }
            List<String> result = new ArrayList<>();
            for(int i=0;i<26;i++) {
                boolean exit = false;
                int min = Integer.MAX_VALUE;
                for(int j=0;j<freqs.length;j++) {
                    if(freqs[j][i]==0) {
                        exit = true;
                        break;
                    }
                    else {
                        min = Math.min(min,freqs[j][i]);
                    }
                }
                if(!exit) {
                    for(int k=0;k<min;k++) {
                        char c = (char)(i + 'a');
                        result.add(Character.toString(c));
                    }
                }
            }
            return result;
        }
        static int [] freq (String a) {
            int [] frequency = new int[26];
            for(char c : a.toCharArray()) {
                frequency[c-'a']++;
            }
            return frequency;
        }

        static void printMap(LinkedHashMap<Integer,Integer> map) {
            for (Map.Entry<Integer,Integer> m : map.entrySet()) {
                System.out.println(m.getKey() + " " + m.getValue());
            }
        }

        static int upperBound(int [] arr, int target) {
            int lo = 0;
            int hi = arr.length - 1;
            while(lo<=hi) {
                int med = hi-(hi-lo)/2;
                if(target>=arr[med]) lo = med + 1;
                else hi = med - 1;
            }
            return hi;
        }
        static int currentDrawBack(int a,int b,int c, int d) {
            int max = Math.max(a,b);
            int min = Math.min(c,d);
            return min-max+1;
        }
        static int lowerBound1(Integer [] a,int target) {
            int lo = 0;
            int hi = a.length - 1;
            while(lo<=hi) {
                int med = hi-(hi-lo)/2;
                if(target<=a[med]) hi = med - 1;
                else lo = med + 1;
            }
            return lo;
        }
        static int lowerBound(int [] a,int target) {
            int lo = 0;
            int hi = a.length - 1;
            while (lo<=hi) {
                int med = hi-(hi-lo)/2;
                if(target<=a[med]) {
                    hi = med - 1;
                }
                else {
                    lo = med + 1;
                }
            }
            return lo;
        }

        private static void reverse(char [] c, int k, int index) {
            for(int i=index;i<(2*index+k)/2;i++) {
                System.out.println(i + " " + (k-index - 1));
                char temp = c[i];
                c[i] = c[k-i-1];
                c[k-i-1] = temp;
            }

        }
        static boolean isVowel(char c) {
            return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
        }
        private static String whoWin(int [] a) {
            TreeMap<Integer,Integer> map = new TreeMap<>(Comparator.reverseOrder());
            for(int n:a) {
                map.put(n,map.getOrDefault(n,0)+1);
            }
            for(Map.Entry<Integer,Integer> m:map.entrySet()) {
                if(m.getValue()%2==1) return "Conan";
            }
            return "Agasa";
        }


        private static int [] prefixSum(int [] a) {
            int [] prefix = new int[a.length+1];
            for(int i=1;i < prefix.length;i++) {
                prefix[i] = prefix[i-1] + a[i-1];
            }
            return prefix;
        }
        private static int [] charFrequency(String a) {
            int [] freq = new int[26];
            char [] cc = a.toCharArray();
            for(char c : cc) {
                freq[c-'a']++;
            }
            return freq;
        }
    }

    class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return tokenizer.nextToken();
        }

        public Integer nextInt() {
            return Integer.valueOf(next());
        }
        public Long nextLong() {return  Long.valueOf(next());}

        static class OutputWriter extends PrintWriter {
            public OutputWriter(OutputStream outputStream) {
                super(outputStream);
            }

            public OutputWriter(Writer writer) {
                super(writer);
            }

            public OutputWriter(String filename) throws FileNotFoundException {
                super(filename);
            }

            public void close() {
                super.close();
            }
        }
    }
