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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class I {

	static int N;
	static int arr[];
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		arr = new int[N];
		for(int i = 0 ; i < N ; i++) arr[i] = sc.nextInt();
		BigInteger ans = new BigInteger("0");
		BigInteger sum = new BigInteger("0");
		HashMap<Integer , Integer> cnt = new HashMap<Integer , Integer> ();
		for(int i = N - 1 ; i >= 0 ; --i){
	        sum = sum.add(new BigInteger(arr[i] + ""));
	        if(cnt.containsKey(arr[i])) {
	        		cnt.put(arr[i] , cnt.get(arr[i]) + 1);
	        } else {
	        		cnt.put(arr[i], 1);
	        }
	        Integer cnt1 = cnt.get(arr[i]);
	        Integer cnt2 = cnt.get(arr[i] + 1);
	        Integer cnt3 = cnt.get(arr[i] - 1);
	        if(cnt2 == null) cnt2 = 0;
	        if(cnt3 == null) cnt3 = 0;
	        BigInteger b1 = new BigInteger(arr[i]+"");
	        b1 = b1.multiply(new BigInteger(cnt1+""));
	        BigInteger b2 = new BigInteger((arr[i] + 1) +"");
	        b2 = b2.multiply(new BigInteger(cnt2+""));
	        BigInteger b3 = new BigInteger((arr[i] - 1)+"");
	        b3 = b3.multiply(new BigInteger(cnt3+""));
	        BigInteger curSum = sum.subtract(b1.add(b2).add(b3)) ;
	        int invalid = cnt1 + cnt2 + cnt3;
	        BigInteger t = new BigInteger((N - i - invalid) + "");
	        t = t.multiply(new BigInteger(arr[i] + ""));
	        ans = ans.add(curSum.subtract(t));
	    }
		out.println(ans.toString());
		out.flush();
		out.close();
	}


	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file)); }
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system)); }
		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() {
			for (long i = 0; i < 3e9; i++); }
	}
}