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.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    protected static final double EPS = 1e-11;
    private static StreamTokenizer in;
    private static Scanner ins;
    private static PrintWriter out;
    protected static final Double[] BAD = new Double[]{null, null};
    private boolean[][] layouts;
    private int c;
    private int b;
    private int a;
    private String word;

    public static void main(String[] args) {

        try {
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            ins = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
            out = new PrintWriter(System.out);
            try {
                if (System.getProperty("xDx") != null) {
                    in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
                    ins = new Scanner(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                }
            } catch (Exception e) {
                in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
                ins = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }
            new Main().run();
        } catch (Throwable e) {
//            e.printStackTrace();
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    private int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    private long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    private double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    private String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    private char nextChar() throws IOException {
        in.nextToken();
        return (char) in.ttype;
    }

    private void run() throws Exception {
        /*int t = nextInt();
        for (int i = 0; i < t; i++) {
            out.printf(Locale.US, "Case #%d: %d\n", i + 1, solve());
        }*/
        solve();
    }

    private void solve() throws IOException {
        int n = ins.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = ins.nextInt();
        }

        Map<Long, Integer> map = new HashMap<>();

        BigInteger res = BigInteger.ZERO;
        long sum = 0;
        long amount = 0;

        for (int i = n - 1; i >= 0; i--) {
            long cur = a[i];
            Pair same = getZeroAmount(cur, map);

            res = res.add(BigInteger.valueOf((sum - same.sum) - cur * (amount - same.amount)));
            amount++;
            sum += cur;
            map.put(cur, map.getOrDefault(cur, 0) + 1);
        }

        out.println(res);
    }

    class Pair {
        long amount;
        long sum;

        public Pair(long amount, long sum) {
            this.amount = amount;
            this.sum = sum;
        }
    }

    private Pair getZeroAmount(long cur, Map<Long, Integer> map) {
        long amount = 0;
        long sum = 0;
        for (long i = cur - 1; i <= cur + 1; i++) {
            long amountI = map.getOrDefault(i, 0);
            amount += amountI;
            sum += amountI * i;
        }
        return new Pair(amount, sum);
    }

    private List<Integer> iterate(List<Integer> a) {
        ArrayList<Integer> b = new ArrayList<>();
        int prev = -1;
        for (int x : a) {
            if (x == prev) {
                b.add(x);
            } else {
                prev = x;
            }
        }
        return b;
    }

    private long gcd(long a, long b) {
        while (a > 0 && b > 0) {
            long k = a % b;
            a = b;
            b = k;
        }

        return a | b;
    }

}