Let's denote a function 

<image>

You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Input

The first line contains one integer n (1 ≤ n ≤ 200000) — the number of elements in a.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of the array. 

Output

Print one integer — the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Examples

Input

5
1 2 3 1 3


Output

4


Input

4
6 6 5 5


Output

0


Input

4
6 6 4 4


Output

-8

Note

In the first example:

  1. d(a1, a2) = 0; 
  2. d(a1, a3) = 2; 
  3. d(a1, a4) = 0; 
  4. d(a1, a5) = 2; 
  5. d(a2, a3) = 0; 
  6. d(a2, a4) = 0; 
  7. d(a2, a5) = 0; 
  8. d(a3, a4) = - 2; 
  9. d(a3, a5) = 0; 
  10. d(a4, a5) = 2. 
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    // 32bit sosu
    static final long[]MODS={1299653,1299673,1299689,1299709};
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        long[]a=new long[n];
        for(int i=0;i<n;++i)a[i]=sc.nextInt();
        int ms=MODS.length;
        long[]ans=new long[ms];
        long dif=0;
        Map<Long,Integer>hm=new HashMap<Long,Integer>();
        for(int i=0;i<n;++i){
            dif-=hm.getOrDefault(a[i]-1,0);
            dif+=hm.getOrDefault(a[i]+1,0);
            hm.put(a[i],hm.getOrDefault(a[i],0)+1);
        }
        for(int b=0;b<ms;++b){
            long m=MODS[b];
            for(int i=0;i<n;++i){
                long v1=(2*i-n+1+m)%m;
                long v2=a[i]%m;
                ans[b]=(ans[b]+v1*v2)%m;
            }
            ans[b]+=m+dif%m;
            ans[b]%=m;
        }
        out.println(Lib.garner(ans,MODS));
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
class Lib{
    /*http://math314.hateblo.jp/entry/2015/05/07/014908*/
    /*
    T extgcd(T a, T b, T& x, T& y) {
        for (T u = y = 1, v = x = 0; a;){
            T q = b / a; swap(x -= q * u, u);
            swap(y -= q * v, v);
            swap(b -= q * a, a);
        }
        return b;
    }
    */
    static long extgcd(long a,long b,long[]x) {
        for (long u = x[1] = 1, v = x[0] = 0; a!=0;){
            long q = b / a;
            x[0] -= q * u;
            long t=x[0];
            x[0]=u;
            u=t;
            x[1] -= q * v;
            t=x[1];
            x[1]=v;
            v=t;
            b -= q * a;
            t=b;
            b=a;
            a=t;
        }
        return b;
    }

    static long mod_inv(long a,long m) {
        long[]x=new long[2];
        extgcd(a, m, x);
        return (m + x[0] % m) % m;
    }
    static BigInteger garner(long[]a,long[]m){
        int ms=a.length;
        long[]coffs=new long[ms],constants=new long[ms];
        long[]digs=new long[ms];
        Arrays.fill(coffs,1);
        for(int i=0;i<ms;++i){
            long v = (a[i] - constants[i]) * mod_inv(coffs[i], m[i]) % m[i];
            if(v<0)v+=m[i];
            digs[i]=v;
            for (int j = i + 1; j < ms; j++) {
                constants[j] += coffs[j] * v;
                constants[j] %= m[j];
                coffs[j] *= m[i];
                coffs[j] %= m[j];
            }
        }
        BigInteger ans=BigInteger.valueOf(0),c=BigInteger.valueOf(1);
        for(int i=ms-1;i>=0;--i){
            c=c.multiply(BigInteger.valueOf(m[i]));
            ans=ans.multiply(BigInteger.valueOf(m[i]));
            ans=ans.add(BigInteger.valueOf(digs[i]));
        }
        if(ans.compareTo(c.divide(BigInteger.valueOf(2)))>0)
            ans=ans.subtract(c);
        return ans;
    }
}

						  	  			  		 			 			   		