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. 
// created by Whiplash99
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class A
{
    public static void main(String[] args) throws IOException
    {
        Reader r=new Reader();

        int i,j,N;
        N=r.nextInt();
        long a[]=new long[N];
        for(i=0;i<N;i++)
            a[i]=r.nextInt();
        HashMap<Long,Integer> map=new HashMap<>();

        long less1[]=new long[N];
        long more1[]=new long[N];

        BigInteger sum=new BigInteger("0");

        for(i=N-1;i>=0;i--)
        {
            less1[i]=map.getOrDefault(a[i]-1,0);
            more1[i]=map.getOrDefault(a[i]+1,0);
            map.put(a[i],map.getOrDefault(a[i],0)+1);
        }

        long dp[]=new long[N+1];
        for(i=0;i<N;i++)
            dp[i+1]=dp[i]+a[i];

        //long sum=0;
        for(i=0;i<N;i++)
        {
            sum=sum.subtract(BigInteger.valueOf((N-i-1)*a[i]));
            sum=sum.add(BigInteger.valueOf(dp[N]-dp[i+1]));
            sum=sum.subtract(BigInteger.valueOf(more1[i]));
            sum=sum.add(BigInteger.valueOf(less1[i]));
        }
        System.out.println(sum);
    }
    static class Reader {
            final private int BUFFER_SIZE = 1 << 16;private DataInputStream din;private byte[] buffer;private int bufferPointer, bytesRead;
            public Reader(){din=new DataInputStream(System.in);buffer=new byte[BUFFER_SIZE];bufferPointer=bytesRead=0;
            }public Reader(String file_name) throws IOException{din=new DataInputStream(new FileInputStream(file_name));buffer=new byte[BUFFER_SIZE];bufferPointer=bytesRead=0;
            }public String readLine() throws IOException{byte[] buf=new byte[64];int cnt=0,c;while((c=read())!=-1){if(c=='\n')break;buf[cnt++]=(byte)c;}return new String(buf,0,cnt);
            }public int nextInt() throws IOException{int ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
            }public long nextLong() throws IOException{long ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
            }public double nextDouble() throws IOException{double ret=0,div=1;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c = read();do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(c=='.')while((c=read())>='0'&&c<='9')ret+=(c-'0')/(div*=10);if(neg)return -ret;return ret;
            }private void fillBuffer() throws IOException{bytesRead=din.read(buffer,bufferPointer=0,BUFFER_SIZE);if(bytesRead==-1)buffer[0]=-1;
            }private byte read() throws IOException{if(bufferPointer==bytesRead)fillBuffer();return buffer[bufferPointer++];
            }public void close() throws IOException{if(din==null) return;din.close();}
        }
}