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

public class Main {
    int[] tree;
    int x = 1;
    int[] y;
    TreeMap<Integer, Integer> q;

    void build(int n) {
        while (x < n) {
            x *= 2;
        }
        tree = new int[2 * x];
    }

    void set(int i) {
        tree[x + i]++;
        i = (x + i) / 2;
        while (i > 1) {
            tree[i]++;
            i /= 2;
        }
    }

    int sum(int a, int l, int r, int min, int max) {
        if (max < 1) {
            return 0;
        }
        if (y[l] > max || y[r] < min) {
            return 0;
        }
        if (y[l] >= min && y[r] <= max) return tree[a];
        return sum(a * 2, l, (l + r) / 2, min, max) + sum(a * 2 + 1, (l + r) / 2 + 1, r, min, max);
    }

    public void solve() throws IOException {
        int n = nextInt();
        q = new TreeMap<>();
        int[] a = new int[n];
        int[] b = new int[n];
        build(n);
        y = new int[x];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            b[i] = a[i];
        }
        int uu = 0;
        Arrays.sort(b);
        for (int i = 0; i < n; i++) {
            if (!q.containsKey(b[i])) {
                q.put(b[i], uu);
                y[uu] = b[i];
                uu++;
            }
        }
        for (int i = uu; i < x; i++) {
            y[i] = Integer.MAX_VALUE;
        }
        BigInteger res = new BigInteger("0");
        for (int i = 0; i < n; i++) {
            long g = (long) (a[i])  * (sum(1, 0, x - 1, Integer.MIN_VALUE, a[i] - 2) + sum(1, 0, x - 1, a[i] + 2, Integer.MAX_VALUE - 1));
            res = res.add(new BigInteger(Long.toString(g)));
            set(q.get(a[i]));
        }
        build(n);
        for (int i = n - 1; i >= 0; i--) {
            long g = (long) (a[i]) * (-1) * (sum(1, 0, x - 1, Integer.MIN_VALUE, a[i] - 2) + sum(1, 0, x - 1, a[i] + 2, Integer.MAX_VALUE - 1));
            res = res.add(new BigInteger(Long.toString(g)));
            set(q.get(a[i]));
        }
        out.print(res);
    }

    StringTokenizer sc;
    BufferedReader br;
    PrintWriter out;

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
            new Main().run();
        } catch (Exception e) {

        }
    }

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

    public void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}