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.InputStream;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.TreeMap;

public class CFD {
    private static final long SEED = 1_000_000_007L;

    static FastScanner sc;
    static TreeMap<Long, Integer> map;

    public static void main(String[] args) {
        sc = new FastScanner(System.in);

        int n = sc.nextInt(); //up to 200,000
        long[] as = readLongArray(n);
        map = new TreeMap<>();

        long mul = n - 1;
        BigInteger sum = BigInteger.ZERO;
        long diff = 0;
        for (int i = 0; i < n/2; i++, mul -= 2) {
            sum = sum.add(BigInteger.valueOf((as[n - i - 1] - as[i]) * mul));
        }

        for (long a: as) {
            map.compute(a, (k, v) -> elvis(v, 0) + 1);
            Map.Entry<Long, Integer> low = map.lowerEntry(a);
            if (low != null) {
                long key = low.getKey();
                int value = low.getValue();
                if (key + 1 == a && value > 0) {
                    diff -= value;
                }
            }

            Map.Entry<Long, Integer> high = map.higherEntry(a);
            if (high != null) {
                long key = high.getKey();
                int value = high.getValue();
                if (key - 1 == a && value > 0) {
                    diff += value;
                }
            }
        }

        sum = sum.add(BigInteger.valueOf(diff));
        System.out.println(sum);
    }

    static BigInteger d(long[] as, int i, int j) {
        if (Math.abs(as[i]-as[j]) <= 1) return BigInteger.ZERO;
        return BigInteger.valueOf(as[j]).subtract(BigInteger.valueOf(as[i]));
    }


    //********************************************************************************************
    //********************************************************************************************
    //********************************************************************************************

    @SuppressWarnings("SameParameterValue")
    private static <T> T elvis(T obj, T defValue) {
        return obj == null ? defValue : obj;
    }

    private static boolean sign(long val) {
        return val >= 0;
    }

    private static int round(double d) {
        return (int) (d + 0.5);
    }

    private static int gcd(int a, int b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    private static int[] readIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextInt();
        }
        return res;
    }

    private static long[] readLongArray(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextLong();
        }
        return res;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

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

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}