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

// :%s/Dedu34/"name"/
// if (debug) 

public class Dedu34 {
	public static void main(String[] args) { new Dedu34(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int t;
	int n;
	long MIN = 0L, MAX = (long)1e9 + 1L;
	long[] a, cs;
	// long ans;
	BigInteger ans;
	wave let;

	boolean debug = !true, multi = !true;

	Dedu34() {
		if (multi) t = in.nextInt();
		do {
			if (multi) if (z(t--)) break;
			
			n = in.nextInt();
			a = new long[n];
			cs = new long[n + 1];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong();
				cs[i + 1] = a[i] + cs[i];
			}
		
			ans = new BigInteger("0");
			let = new wave(a);
			for (int i = 0; i < n; i++) {


				long below = 0, above = 0;
				long cntBel = 0, cntAbv = 0;
				if (a[i] - 2 > MIN) {
					below = let.sumBtwnLoHi(i, n, MIN, a[i] - 2);
					cntBel = let.box(i + 1, n, MIN, a[i] - 2);
					below -= a[i] * cntBel;
				}
				if (a[i] + 2 < MAX) {
					above = let.sumBtwnLoHi(i, n, a[i] + 2, MAX);
					cntAbv = let.box(i + 1, n, a[i] + 2, MAX);
					above -= a[i] * cntAbv;
				}
				ans = ans.add(new BigInteger(Long.toString((below + above))));
			}
			out.println(ans);
		} while (debug || multi);
		out.close();
	}

	class wave {
		int sz;
		long min, mid, max;
		int[] sig;
		long[] arr, prf;
		wave L, R;

		wave (long[] tide) {
			sz = tide.length;
			min = tide[0]; 
			max = tide[0];
			arr = new long[sz];
			prf = new long[sz + 1];
			for (int i = 0; i < sz; i++) {
				prf[i + 1] = prf[i];
				prf[i + 1] += (arr[i] = tide[i]);
				min = min(min, arr[i]);
				max = max(max, arr[i]);
			}
			mid = min + (max - min) / 2;
			if (min == max)
				return;
			sig = new int[sz + 1];
			for (int i = 1; i <= sz; i++) {
				sig[i] = sig[i - 1];
				if (arr[i - 1] <= mid)
					sig[i]++;
			}
			
			int l = 0, r = 0;
			long[] left = new long[sig[sz]];
			long[] right = new long[sz - sig[sz]];
			for (int i = 1; i <= sz; i++) {
				if (sig[i - 1] != sig[i])
					left[l++] = arr[i - 1];
				else
					right[r++] = arr[i - 1];
			}

			L = new wave(left); 
			R = new wave(right);
		}

		long kth(int l, int r, int k) {
			if (min == max)
				return min;
			int ll = sig[l], lr = sig[r];
			if (k <= ll - lr)
				return L.kth(ll, lr, k);
			else
				return R.kth(l - ll, r - lr, k - (ll - lr));
		}

		int box(int l, int r, long lo, long hi) {
			if (lo <= min && max <= hi)
				return r - l;
			if (max < lo || hi < min || min == max)
				return 0;
			int ll = sig[l], lr = sig[r];
			int ans = 0;
			ans += L.box(ll, lr, lo, hi);
			ans += R.box(l - ll, r - lr, lo, hi);
			return ans;
		}

		long sumBtwnLoHi(int l, int r, long lo, long hi) {
			if (lo <= min && max <= hi)
				return prf[r] - prf[l];
			if (max < lo || hi < min || min == max)
				return 0;
			int ll = sig[l], lr = sig[r];
			long ans = 0;
			ans += L.sumBtwnLoHi(ll, lr, lo, hi);
			ans += R.sumBtwnLoHi(l - ll, r - lr, lo, hi);
			return ans;
		}

		void debug(int idx) {
			out.printf("%s: (%d | [%d, %d] --> %d | %s%n", idx == 0 ? "root" : idx == 1 ? "L" : "R", sz, min, max, mid, Arrays.toString(arr));
			out.printf("this dudes cum sum = %s%n", Arrays.toString(prf));
			if (L == null)
				return;
			L.debug(1);
			if (R == null)
				return;
			R.debug(2);
		}
	}	

	int min(int a, int b) { if (a < b) return a; return b; }	
	int max(int a, int b) { if (a > b) return a; return b; }	
	long min(long a, long b) { if (a < b) return a; return b; }	
	long max(long a, long b) { if (a > b) return a; return b; }	

	boolean z(int x) { if (x == 0) return true; return false; }	
	boolean z(long x) { if (x == 0) return true; return false; }	

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}
