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

public class D {
	public static Scanner sc = new Scanner(System.in);
	public static StringTokenizer st;
	public static PrintWriter pw = new PrintWriter(System.out);
	final static boolean debugmode = false;
	public static void main(String[] args) {
		int numberofeles = getInt();
		HashMap<Integer,Integer> counts = new HashMap<Integer,Integer>();
		int[] c = new int[numberofeles];
		BigInteger sum = new BigInteger("0");
		BigInteger solution = new BigInteger("0");
		for(int i = 0;i<numberofeles;i++){
			c[i] = getInt();
			counts.put(c[i], counts.getOrDefault(c[i], 0) + 1);
			sum = sum.add(new BigInteger(Integer.toString(c[i])) );
		}
		debug("prelim of "+sum);
		for(int scanner_elemnt = 0;scanner_elemnt < c.length;scanner_elemnt++ ){
			debug("handling: "+c[scanner_elemnt] + " with current solution of: "+solution);
			BigInteger ourelement = new BigInteger(Integer.toString(c[scanner_elemnt]));
			sum = sum.subtract(ourelement);
			debug("current sum: "+sum);
			debug("amount above: "+(counts.getOrDefault(c[scanner_elemnt]+1,0) + " amount below: "+counts.getOrDefault(c[scanner_elemnt]-1, 0)));
			BigInteger ones_to_take_off = new BigInteger(Integer.toString(counts.getOrDefault(c[scanner_elemnt]+1, 0) - counts.getOrDefault(c[scanner_elemnt]-1, 0)));
			debug("offbyone compensate: "+ones_to_take_off);
			BigInteger times = new BigInteger(Integer.toString(c.length - scanner_elemnt - 1));
			debug("times: "+times);
			solution = solution.add(sum.subtract(ourelement.multiply(times)).subtract(ones_to_take_off) );
			counts.put(c[scanner_elemnt], counts.get(c[scanner_elemnt]) -1);
		}
		submit(solution);
	}
	public static void debug(String toPrint){
		if(!debugmode) {return;}
		pw.println("[DEBUG]: "+toPrint);
	}
	public static void  submit(int[] k){
		pw.println(Arrays.toString(k));
		pw.close();
	}
	public static void submit(int p){
		pw.println(Integer.toString(p));
		pw.close();
	}
	public static void submit(BigInteger p){
		pw.println(p.toString());
		pw.close();
	}
	public static void submit(String k){
		pw.println(k);
		pw.close();
	}
	public static void submit(double u){
		pw.println(Double.toString(u));
		pw.close();
	}
	public static void submit(long lng){
		pw.println(Long.toString(lng));
		
	}
	public static int getInt(){
		if (st != null && st.hasMoreTokens()){
			return Integer.parseInt(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Integer.parseInt(st.nextToken());
	}
	public static long getLong(){
		if (st != null && st.hasMoreTokens()){
			return Long.parseLong(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Long.parseLong(st.nextToken());
	}
	public static double getDouble(){
		if (st != null && st.hasMoreTokens()){
			return Double.parseDouble(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Double.parseDouble(st.nextToken());
	}
	public static String getString(){
		if(st != null && st.hasMoreTokens()){
			return st.nextToken();
		}
		st = new StringTokenizer(sc.nextLine());
		return st.nextToken();
	}
	public static String getLine(){
		return sc.nextLine();
	}
	public static int[][] readMatrix(int lines,int cols){
		int[][] matrr = new int[lines][cols];
		for (int i = 0;i < lines;i++){
			for(int j = 0;j < cols;j++){
				matrr[i][j] = getInt();
			}
		}
		return matrr;
	}
	public static int[] readArray(int lines){
		int[] ar = new int[lines];		
		for (int i = 0;i<lines;i++) ar[i] =getInt();
		return ar;
	}
	
}
