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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        int MX = (int) 2e5 + 10;
        long[] cnt;
        long[] sum;
        int sz;

        void add(long arr[], int idx, long val) {

            while (idx <= sz) {
                arr[idx] += val;
                idx += idx & -idx;
            }
        }

        long query(long arr[], int idx) {

            long res = 0;
            while (idx > 0) {
                res += arr[idx];
                idx -= idx & -idx;
            }

            return res;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();

            cnt = new long[MX];
            sum = new long[MX];

            int[] a, q;
            a = new int[n];
            q = new int[n];

            TreeMap<Integer, Integer> c = new TreeMap<>();
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                q[i] = a[i];
                c.put(a[i], c.getOrDefault(a[i], 0) + 1);
            }

            Arrays.sort(q);
            q = Arrays.stream(q).distinct().toArray();
            sz = q.length;

            TreeMap<Integer, Integer> idx = new TreeMap<>();
            for (int i = 0; i < sz; ++i) {
                idx.put(q[i], i);
                int cc = c.get(q[i]);
                add(cnt, i + 1, cc);
                add(sum, i + 1, cc * 1L * q[i]);
            }

            BigInteger res = BigInteger.ZERO;
            for (int i = 0; i < n; ++i) {

                int q_idx = idx.get(a[i]);

                int R_idx = q_idx + 1;
                while (R_idx < sz && (q[R_idx] - a[i]) <= 1) R_idx++;

                BigInteger R = BigInteger.ZERO, L = BigInteger.ZERO;

                if (R_idx < sz) {
                    long c1 = query(cnt, sz) - query(cnt, R_idx);
                    long val = query(sum, sz) - query(sum, R_idx);
                    R = BigInteger.valueOf(val).subtract(BigInteger.valueOf(c1 * a[i]));
                }

                int L_idx = q_idx - 1;
                while (L_idx >= 0 && (a[i] - q[L_idx]) <= 1) L_idx--;

                if (L_idx >= 0) {
                    long c1 = query(cnt, L_idx + 1);
                    long val = query(sum, L_idx + 1);
                    L = BigInteger.valueOf(val).subtract(BigInteger.valueOf(c1 * a[i]));
                }

                // cout << a[i] << " " << R_idx << " " << L_idx << " " << L << " " << R << endl
                res = res.add(L);
                res = res.add(R);

                add(cnt, q_idx + 1, -1);
                add(sum, q_idx + 1, -a[i]);
            }

            out.println(res.toString());

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public String test_string;

        public InputReader(InputStream test_stringeam) {
            reader = new BufferedReader(new InputStreamReader(test_stringeam), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = null;
                    if (test_string != null) {
                        line = test_string;
                        test_string = null;
                    } else
                        line = reader.readLine();

                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

