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.math.BigInteger;
import java.util.Scanner;

public class d {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] arr = new int[N];
		for(int n=0;n<N;n++){
			arr[n] = in.nextInt();
		}
		
		Wavelet waveyMcWaveFace = new Wavelet(arr);
		
		BigInteger bigSum = BigInteger.ZERO;
		for(int n=0;n<N;n++){
			// calculate the amount added for all j = n all at once
			// it's a[j] - a[i]
			
			// step one
			// positive part
			long amtPlus = arr[n] * (long)(waveyMcWaveFace.numValsBtwn(1, arr[n] - 2, 0, n)
										+ waveyMcWaveFace.numValsBtwn(arr[n] + 2, 2147483647, 0, n));
			
			// step two
			// negative part
			long amtMinus = waveyMcWaveFace.sumOfValsBtwn(1, arr[n] - 2, 0, n)
							+ waveyMcWaveFace.sumOfValsBtwn(arr[n] + 2, 2147483647, 0, n);
			
//			System.out.println(amtPlus+" "+amtMinus);
			bigSum = bigSum.add(new BigInteger(""+(amtPlus - amtMinus)));
		}
		
		System.out.println(bigSum);
	}
	static class Wavelet{
		int l = 2147483647, h = -2147483648;
		int[] arr, ldex, hdex;
		long[] sum;
		Wavelet low = null, high = null;
		Wavelet(int[] arr){
			this.arr = arr;
			for(int i : arr){
				l = Math.min(l, i);
				h = Math.max(h, i);
			}
			ldex = new int[arr.length + 1];
			hdex = new int[arr.length + 1];
			sum = new long[arr.length + 1];
			int mid = l + (h - l) / 2;
			for(int n = 0; n < arr.length; n++){
				sum[n+1] = sum[n] + arr[n];
				if(arr[n] > mid){
					ldex[n+1] = ldex[n];
					hdex[n+1] = hdex[n] + 1;
				}
				else{
					ldex[n+1] = ldex[n] + 1;
					hdex[n+1] = hdex[n];
				}
			}
			if(l == h) return;
			int[] larr = new int[ldex[arr.length]];
			int[] harr = new int[hdex[arr.length]];
			for(int n=0;n<arr.length;n++){
				if(hdex[n] == hdex[n+1]){
					larr[ldex[n]] = arr[n];
				}
				else{
					harr[hdex[n]] = arr[n];
				}
			}
			low = new Wavelet(larr);
			high = new Wavelet(harr);
		}
		// range [ll, rr)
		int kthLowest(int k, int ll, int rr){
			if(l == h){
				return arr[ll + k-1];
			}
			if(ldex[rr] - ldex[ll] >= k){
				return low.kthLowest(k, ldex[ll], ldex[rr]);
			}
			return high.kthLowest(k - ldex[rr] + ldex[ll], hdex[ll], hdex[rr]);
		}
		// number of values in between [lo, hi] in range [ll, rr)
		int numValsBtwn(int lo, int hi, int ll, int rr){
			if(hi < lo) return 0;
			if(lo <= l && h <= hi){
				return rr - ll;
			}
			if(l == h) return 0;
			if(hi < high.l){
				return low.numValsBtwn(lo, hi, ldex[ll], ldex[rr]);
			}
			if(low.h < lo){
				return high.numValsBtwn(lo, hi, hdex[ll], hdex[rr]);
			}
			return low.numValsBtwn(lo, hi, ldex[ll], ldex[rr])
					+ high.numValsBtwn(lo, hi, hdex[ll], hdex[rr]);
		}
		// sum of values between [lo, hi] in range [ll, rr)
		long sumOfValsBtwn(int lo, int hi, int ll, int rr){
			if(lo <= l && h <= hi){
				return sum[rr] - sum[ll];
			}
			if(l == h) return 0;
			if(hi < high.l){
				return low.sumOfValsBtwn(lo, hi, ldex[ll], ldex[rr]);
			}
			if(low.h < lo){
				return high.sumOfValsBtwn(lo, hi, hdex[ll], hdex[rr]);
			}
			return low.sumOfValsBtwn(lo, hi, ldex[ll], ldex[rr])
					+ high.sumOfValsBtwn(lo, hi, hdex[ll], hdex[rr]);
		}
	}
}
