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

public class d {
	

	public static void main(String args[]) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//BEGIN HERE
		int n = in.nextInt();
		int numbers[] = new int[n];
		HashMap<Integer, Integer> mp = new HashMap<>();
		TreeSet<Integer> ts = new TreeSet<>();
		for(int i = 0; i < n; i++){ 
			numbers[i] = in.nextInt();
			ts.add(numbers[i]);
		}
		
		BIT ft = new BIT(ts.size() + 1);
		BIT fr = new BIT(ts.size() + 1);
		Iterator<Integer> itr = ts.iterator();
		int idx = 0;
		while(itr.hasNext()) {
			mp.put(itr.next(), idx++);
		}
		BigInteger ans = BigInteger.ZERO;
		for(int i = 0; i < n; i++) {
			long v = numbers[i];
			Integer lb = (int)v - 2;
			lb = ts.floor(lb);
			if(lb != null) {
				int li = mp.get(lb);
				BigInteger a = BigInteger.valueOf(fr.rsq(0, li));
				BigInteger b = BigInteger.valueOf(v);
				BigInteger c = BigInteger.valueOf(ft.rsq(0, li));
				ans = ans.add(a.multiply(b).subtract(c));
				
			}
			Integer rb = (int)v + 2;
			rb = ts.ceiling(rb);
			if(rb != null) {
				int ri = mp.get(rb);
				BigInteger a = BigInteger.valueOf(fr.rsq(ri, ts.size()));
				BigInteger b = BigInteger.valueOf(v);
				BigInteger c = BigInteger.valueOf(ft.rsq(ri, ts.size()));
				ans = ans.add(a.multiply(b).subtract(c));// * v - ft.rsq(ri, ts.size());
			}
			fr.adjust(mp.get((int)v), 1);
			ft.adjust(mp.get((int)v), v);
		}
		out.println(ans);
		out.close();
	}
	
	public static class BIT {
		private  long ft[], sum, maxi, N;
		BIT(int n) {
			ft = new long[n+1];
			maxi = -1;
			while((1 << maxi) <= n+1) {
				maxi++;
			}
			maxi--;
			N = n;
		}
		
		public  long rsq(int b) {
			b++;sum = 0;
			for(;b!=0;b -= b &-b) sum += ft[b];
			return sum;
		}
		
		public long rsq(int a, int b) {
			if(b < a) return 0;
			return rsq(b) - (a==0?0:rsq(a-1));
		}
		
		void adjust(int k, long v) {
			k++;
			for(;k < ft.length; k += k&-k) ft[k] += v;
		}
		
		
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			if (st == null) {
				st = new StringTokenizer(br.readLine());
			}
			String line = st.nextToken("\n");
			st = null;
			return line;
		}

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

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

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