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. 
//stan hu tao
//join nct ridin by first year culture reps
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;

public class x903D
{
    public static void main(String hi[]) throws Exception
    {
        FastScanner infile = new FastScanner();
        int N = infile.nextInt();
        int[] arr = infile.nextInts(N);     M = 1;
        HashMap<Integer, Integer> map = compress(arr, N);
        int[] vals = new int[M+1];
        for(int key: map.keySet())
            vals[map.get(key)] = key;
        FenwickTree bit1 = new FenwickTree(M+2); //frequencies
        FenwickTree bit2 = new FenwickTree(M+2);
        BigInteger res = new BigInteger("0");
        long extra = 0L;
        for(int i=0; i < N; i++)
        {
            //arr[x] < arr[i]
            int id = map.get(arr[i]);
            long cnt = bit1.find(1, id-1);
            long sum = bit2.find(1, id-1);
            BigInteger temp = new BigInteger(cnt+"");
            temp = temp.multiply(new BigInteger(arr[i]+""));
            res = res.add(temp);
            res = res.subtract(new BigInteger(sum+""));
            if(id > 1 && vals[id-1]+1 == arr[i])
                extra -= bit1.find(id-1, id-1);
            //arr[x] > arr[i]
            cnt = bit1.find(id+1, M);
            sum = bit2.find(id+1, M);
            temp = new BigInteger(cnt+"");
            temp = temp.multiply(new BigInteger(arr[i]+""));
            res = res.add(temp);
            res = res.subtract(new BigInteger(sum+""));
            if(id < M && vals[id+1]-1 == arr[i])
                extra += bit1.find(id+1, id+1);
            bit1.add(id, 1);
            bit2.add(id, arr[i]);
        }
        res = res.add(new BigInteger(extra+""));
        System.out.println(res);
    }
    static int M;
    public static HashMap<Integer, Integer> compress(int[] arr, int N)
    {
        ArrayList<Integer> ls = new ArrayList<Integer>();
        for(int x: arr)
            ls.add(x);
        Collections.sort(ls);
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int x: ls)
            if(!map.containsKey(x))
                map.put(x, M++);
        M--;
        return map;
    }
}
class FenwickTree
{
    //1 indexed
    public long[] tree;
    public int size;

    public FenwickTree(int size)
    {
        this.size = size;
        tree = new long[size+5];
    }
    public void add(int i, int v)
    {
        while(i <= size)
        {
            tree[i] += v;
            i += i&-i;
        }
    }
    public long find(int i)
    {
        long res = 0L;
        while(i >= 1)
        {
            res += tree[i];
            i -= i&-i;
        }
        return res;
    }
    public long find(int l, int r)
    {
        return find(r)-find(l-1);
    }
}
class FastScanner
{
    private int BS = 1 << 16;
    private char NC = (char) 0;
    private byte[] buf = new byte[BS];
    private int bId = 0, size = 0;
    private char c = NC;
    private double cnt = 1;
    private BufferedInputStream in;

    public FastScanner() {
        in = new BufferedInputStream(System.in, BS);
    }

    public FastScanner(String s) {
        try {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        } catch (Exception e) {
            in = new BufferedInputStream(System.in, BS);
        }
    }

    private char getChar() {
        while (bId == size) {
            try {
                size = in.read(buf);
            } catch (Exception e) {
                return NC;
            }
            if (size == -1) return NC;
            bId = 0;
        }
        return (char) buf[bId++];
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public int[] nextInts(int N) {
        int[] res = new int[N];
        for (int i = 0; i < N; i++) {
            res[i] = (int) nextLong();
        }
        return res;
    }

    public long[] nextLongs(int N) {
        long[] res = new long[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextLong();
        }
        return res;
    }

    public long nextLong() {
        cnt = 1;
        boolean neg = false;
        if (c == NC) c = getChar();
        for (; (c < '0' || c > '9'); c = getChar()) {
            if (c == '-') neg = true;
        }
        long res = 0;
        for (; c >= '0' && c <= '9'; c = getChar()) {
            res = (res << 3) + (res << 1) + c - '0';
            cnt *= 10;
        }
        return neg ? -res : res;
    }

    public double nextDouble() {
        double cur = nextLong();
        return c != '.' ? cur : cur + nextLong() / cnt;
    }

    public double[] nextDoubles(int N) {
        double[] res = new double[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextDouble();
        }
        return res;
    }

    public String next() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c > 32) {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public String nextLine() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c != '\n') {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public boolean hasNext() {
        if (c > 32) return true;
        while (true) {
            c = getChar();
            if (c == NC) return false;
            else if (c > 32) return true;
        }
    }
}