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.math.BigInteger;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static final long INF = (long) 1e18;

    public static void main(String[] args) throws Exception {
        //============================================//
        //answer here:
        int n = scanner.nextInt();
        int arr[] = scanner.readArray(n);
        BigInteger presum = new BigInteger("0");
        BigInteger ans = new BigInteger("0");
        HashMap<Integer, Integer> hm = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int cur = arr[i];
            hm.put(cur, (hm.getOrDefault(cur, 0) + 1));
            presum=presum.add(BigInteger.valueOf(cur));
            long dec = hm.getOrDefault(cur - 1, 0);
            long inc = hm.getOrDefault(cur + 1, 0);
            BigInteger val = presum.subtract(BigInteger.valueOf(dec * (cur - 1))).subtract(BigInteger.valueOf(inc * (cur + 1)));
            long rep = (i + 1) - dec - inc;
            val = BigInteger.valueOf(rep * cur).subtract(val);
            ans = ans.add(val);
        }
        out.println(ans);
        //============================================//
        out.close();
    }

    public static int gcd(int a, int b) {
        return (a == 0) ? b : gcd(b % a, a);
    }
}


class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream system) {
        br = new BufferedReader(new InputStreamReader(system));
    }

    public Scanner(String file) throws Exception {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public char nextChar() throws IOException {
        return next().charAt(0);
    }

    public Long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public boolean ready() throws IOException {
        return br.ready();
    }

    public void waitForInput() throws InterruptedException {
        Thread.sleep(3000);
    }

    int[] readArray(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    long[] readLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

class pair implements Comparable<pair> {
    int t;
    int c;

    public pair(int t, int c) {
        this.t = t;
        this.c = c;
    }

    @Override
    public String toString() {
        return t + "" + c;
    }

    @Override
    public int compareTo(pair o) {
        return o.t - t;
    }
}