import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class main
{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	private PrintWriter pw;
	private long mod = 1000000000 + 7;

	private StringBuilder ans_sb;
	private ArrayList<Integer> primes;
	private long ans;

	private void soln()
	{
		int n = nextInt();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextLong();
		Segment tree = new Segment(n, arr);
		long[] ans = new long[n];
		BigInteger fa = BigInteger.ZERO;
		HashMap<Long, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++)
		{
			ans[i] = ((long) i + 1) * arr[i] - tree.query(0, i);
			if (map.containsKey(arr[i] - 1))
			{
				long tmp = map.get(arr[i] - 1);
				ans[i] -= tmp;
			}
			if (map.containsKey(arr[i] + 1))
			{
				long tmp = map.get(arr[i] + 1);
				ans[i] += tmp;
			}

			if (!map.containsKey(arr[i]))
				map.put(arr[i], 0);
			map.put(arr[i], map.get(arr[i]) + 1);
			fa = fa.add(new BigInteger(Long.toString(ans[i])));
		}
		// debug(ans);
		/*
		 * Node[] nn = new Node[n]; for(int i=0;i<n;i++) { nn[i] = new Node();
		 * nn[i].node = i; nn[i].dist = arr[i]; } //debug(fa); Arrays.sort(nn);
		 * //debug(nn); for(int i=0;i<n-1;i++) { if(nn[i].dist + 1 == nn[i+1].dist) {
		 * System.out.println(nn[i].node +" "+nn[i+1].node); if(nn[i].node >
		 * nn[i+1].node) { fa++; }else fa--; } }
		 */
		pw.println(fa.toString());
		// int k = nextInt();
		// int n = nextInt();
		// String[] arr = new String[k];
		// for(int i=0;i<k;i++)
		// arr[i] = nextLine();
		// HashSet<String> set1 = new HashSet<>();
		// for(int i=0;i<k;i++)
		// set1.add(arr[i]);
		// if(set1.size() == 1) {
		// String s = arr[0];
		// pw.print(s.charAt(1));
		// pw.print(s.charAt(0));
		// for(int i=2;i<n;i++)
		// pw.print(s.charAt(i));
		// }else {
		// String s1 = arr[0];
		// set1.remove(arr[0]);
		// HashSet<Integer>[] aa = new HashSet[set1.size()];
		// ArrayList<String> set = new ArrayList<>();
		// for(String s:set1)
		// set.add(s);
		// int k1 = 0;
		// boolean f1 = false;
		// for(String s:set) {
		// aa[k1] = new HashSet<>();
		// for(int i=0;i<n;i++)
		// if(s1.charAt(i) != s.charAt(i))
		// aa[k1].add(i);
		// if(aa[k1].size() > 4) {
		// pw.println(-1);
		// f1 = true;
		// }
		// k1++;
		// }
		// //debug(set);
		// char[] ch = s1.toCharArray();
		//
		// boolean[] f11 = new boolean[set.size()];
		// int k2 = 0;
		// for(String s:set) {
		// int[] freq = new int[26];
		// for(int i=0;i<n;i++)
		// freq[s.charAt(i)-'a']++;
		// boolean kuu = false;
		// for(int i=0;i<26;i++)
		// if(freq[i] >= 2) {
		// kuu = true;
		// break;
		// }
		// f11[k2] = true;
		// k2++;
		// }
		// // debug(f11);
		//
		// for(int i=0;i<n;i++) {
		// if(f1)
		// break;
		// for(int j=i+1;j<n;j++) {
		// if(f1)
		// break;
		// //System.out.println(i+" "+j);
		// char tmp = ch[i];
		// ch[i] = ch[j];
		// ch[j] = tmp;
		// k1 = 0;
		// HashSet<Integer> haha = new HashSet<>();
		// boolean f = true;
		// for(String s:set) {
		// HashSet<Integer> indi = aa[k1];
		// boolean h1 = false;
		// boolean h2 = false;
		// if(!indi.contains(i)) {
		// indi.add(i);
		// h1 = true;
		// }
		// if(!indi.contains(j)) {
		// indi.add(j);
		// h2 = true;
		// }
		// int cnt = 0;
		// for(int ii:indi) {
		// if(s.charAt(ii) != ch[ii])
		// cnt++;
		// }
		// /*if(i==1 && j==3) {
		// System.out.println(cnt+" "+i+" "+j+" "+s);
		// debug(indi);
		// }*/
		// if(cnt > 2 ) {
		// f = false;
		// break;
		// }
		// if(cnt ==1 && !f11[k1]) {
		// f = false;
		// break;
		// }
		// if(h1)
		// indi.remove(i);
		// if(h2)
		// indi.remove(j);
		// k1++;
		//
		// }
		// if(f) {
		// for(int i1=0;i1<n;i1++) {
		// pw.print(ch[i1]);
		// }
		// f1 = true;
		// break;
		// }
		// tmp = ch[i];
		// ch[i] = ch[j];
		// ch[j] = tmp;
		// }
		// }
		// if(!f1)
		// pw.println(-1);
		// }
	}

	public class Segment
	{
		private Node[] tree;
		private boolean[] lazy;
		private int size;
		private int n;
		private long[] base;

		private class Node
		{
			private int l;
			private int r;
			private long ans;
			private long ans2;
		}

		public Segment(int n, long[] arr)
		{
			this.base = arr;
			int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
			size = 2 * (int) Math.pow(2, x) - 1;
			tree = new Node[size];
			lazy = new boolean[size];
			this.n = n;
			// this.set = set1;
			build(0, 0, n - 1);
		}

		public void build(int id, int l, int r)
		{
			if (l == r)
			{
				tree[id] = new Node();
				tree[id].l = l;
				tree[id].r = r;
				tree[id].ans = base[l];
				return;
			}
			int mid = (l + r) / 2;
			build(2 * id + 1, l, mid);
			build(2 * id + 2, mid + 1, r);
			tree[id] = merge(tree[2 * id + 1], tree[2 * id + 2], l, r);
			// System.out.println(l+" "+r+" "+tree[id].l+" "+tree[id].r+" "+tree[id].ans);
		}

		public Node merge(Node n1, Node n2, int l, int r)
		{
			Node ret = new Node();
			if (n1 == null && n2 == null)
				return null;
			else if (n1 == null)
			{
				ret.ans = n2.ans;
			}

			else if (n2 == null)
			{
				ret.ans = n1.ans;
			} else
			{

				ret.ans = n1.ans + n2.ans;

			}

			return ret;
		}

		public long query(int l, int r)
		{
			Node ret = queryUtil(l, r, 0, 0, n - 1);
			if (ret == null)
			{
				return 0;
			} else
				return ret.ans;
		}

		private Node queryUtil(int x, int y, int id, int l, int r)
		{
			if (l > y || x > r)
				return null;
			if (x <= l && r <= y)
			{
				return tree[id];
			}
			int mid = l + (r - l) / 2;
			// shift(id);
			Node q1 = queryUtil(x, y, 2 * id + 1, l, mid);
			Node q2 = queryUtil(x, y, 2 * id + 2, mid + 1, r);

			return merge(q1, q2, Math.max(l, x), Math.min(r, y));
		}

		public void update(int x, int y, int c)
		{
			update1(x, y, c, 0, 0, n - 1);
		}

		private void update1(int x, int y, int colour, int id, int l, int r)
		{
			// System.out.println(l+" "+r+" "+x);
			if (x > r || y < l)
				return;
			if (x <= l && r <= y)
			{
				if (colour != -1)
				{
					tree[id] = new Node();
					tree[id].ans = 1;
				} else
					tree[id] = null;
				return;
			}
			int mid = l + (r - l) / 2;
			// shift(id);
			if (y <= mid)
				update1(x, y, colour, 2 * id + 1, l, mid);
			else if (x > mid)
				update1(x, y, colour, 2 * id + 2, mid + 1, r);
			else
			{
				update1(x, y, colour, 2 * id + 1, l, mid);
				update1(x, y, colour, 2 * id + 2, mid + 1, r);
			}
			tree[id] = merge(tree[2 * id + 1], tree[2 * id + 2], l, r);

		}

		public void print(int l, int r, int id)
		{
			if (l == r)
			{
				if (tree[id] != null)
					System.out.println(l + " " + r + " " + tree[id].l + " " + tree[id].r + " " + tree[id].ans + " "
							+ tree[id].ans2);
				return;
			}
			int mid = l + (r - l) / 2;
			print(l, mid, 2 * id + 1);
			print(mid + 1, r, 2 * id + 2);
			if (tree[id] != null)
				System.out.println(
						l + " " + r + " " + tree[id].l + " " + tree[id].r + " " + tree[id].ans + " " + tree[id].ans2);
		}

		public void shift(int id)
		{

		}
	}

	private class Node implements Comparable<Node>
	{
		int node;
		long dist;

		@Override
		public int compareTo(Node arg0)
		{
			if (this.dist != arg0.dist)
				return (int) (this.dist - arg0.dist);
			return this.node - arg0.node;
		}

		public boolean equals(Object o)
		{
			if (o instanceof Node)
			{
				Node c = (Node) o;
				return this.node == c.node && this.dist == c.dist;
			}
			return false;
		}

		public String toString()
		{
			return this.node + ", " + this.dist;
		}
	}

	private void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}

	private long pow(long a, long b, long c)
	{
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}

	private long gcd(long n, long l)
	{
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}

	public static void main(String[] args) throws Exception
	{
		new Thread(null, new Runnable()
		{
			@Override
			public void run()
			{
				new main().solve();
			}
		}, "1", 1 << 26).start();
	}

	public StringBuilder solve()
	{
		InputReader(System.in);
		/*
		 * try { InputReader(new FileInputStream("C:\\Users\\hardik\\Desktop\\in.txt"));
		 * } catch(FileNotFoundException e) {}
		 */
		pw = new PrintWriter(System.out);
		ans_sb = new StringBuilder();
		soln();

		pw.close();
		// System.out.println(ans_sb);
		return ans_sb;
	}

	public void InputReader(InputStream stream1)
	{
		stream = stream1;
	}

	private boolean isWhitespace(int c)
	{
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c)
	{
		return c == '\n' || c == '\r' || c == -1;
	}

	private int read()
	{
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars)
		{
			curChar = 0;
			try
			{
				numChars = stream.read(buf);
			} catch (IOException e)
			{
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private int nextInt()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-')
		{
			sgn = -1;
			c = read();
		}
		int res = 0;
		do
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private long nextLong()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-')
		{
			sgn = -1;
			c = read();
		}
		long res = 0;
		do
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private String nextToken()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private String nextLine()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private int[] nextIntArray(int n)
	{
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}

	private long[] nextLongArray(int n)
	{
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextLong();
		}
		return arr;
	}

	private void pArray(int[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private void pArray(long[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private boolean isSpaceChar(int c)
	{
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private char nextChar()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

	private interface SpaceCharFilter
	{
		public boolean isSpaceChar(int ch);
	}
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class D implements Runnable{
	public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int n = fs.nextInt();
		Pair[] a = new Pair[n], b = new Pair[n];
		for(int i = 0; i < n; i++) {
			a[i] = new Pair(fs.nextInt(), i+1);
			b[i] = new Pair(a[i].val, a[i].id);
		}
		Arrays.sort(a);

		Fenwick_Tree ft = new Fenwick_Tree(n), ftFreq = new Fenwick_Tree(n);
		BigInteger res = BigInteger.ZERO;
		int[] update = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++) {
//			System.out.println(sum + " " + a[i].val);
			if(i + 1 == n || (i + 1 < n && a[i+1].val != a[i].val)) {
				update[i] = sum+1;
				sum = 0;
			}
			else {
				sum++;
			}
		}
//		System.out.println(Arrays.toString(update));
		for(int i = 0; i < n; i++) {
			int pos = a[i].id;
			long val = a[i].val;
			long right = ft.sum(n) - ft.sum(pos);
			long freq = ftFreq.sum(n) - ftFreq.sum(pos);

//			System.out.println(a[i].val + " " + a[i].id + " " + right + " " + freq);

			res = add(res, right - (val * freq));
//			res += right - (val * freq);

			long left = ft.sum(pos);
			freq = ftFreq.sum(pos);
			res = add(res, (val * freq) - left);
//			res += (val * freq) - left;

//			System.out.println(a[i].val + " " + a[i].id + " " + left + " " + freq);
//			System.out.println();

			if(update[i] > 0) {
				ft.update(pos, val);
				ftFreq.update(pos, 1);
				int ptr = i-1;
				while(ptr >= 0 && update[ptr] == 0) {
					ft.update(a[ptr].id, val);
					ftFreq.update(a[ptr].id, 1);
					ptr--;
				}
			}
		}

		HashMap<Integer, Integer> freq = new HashMap<>();
		for(int i = n-1; i >= 0; i--) {
			if(!freq.containsKey(b[i].val+1)) {
				if(!freq.containsKey(b[i].val)) freq.put(b[i].val, 0);
				freq.put(b[i].val, freq.get(b[i].val)+1);
				continue;
			}
			long fr = freq.get(b[i].val+1);
//			System.out.println(i + " " + b[i].val + " " + fr);
			res = sub(res, fr * (b[i].val+1) - (fr * (b[i].val)));
//			res -= (fr*(b[i].val+1)) - (fr*b[i].val);
			if(!freq.containsKey(b[i].val)) freq.put(b[i].val, 0);
			freq.put(b[i].val, freq.get(b[i].val)+1);
 		}

//		System.out.println(res);
		freq.clear();

		for(int i = 0; i < n; i++) {
			if(!freq.containsKey(b[i].val+1)) {
				if(!freq.containsKey(b[i].val)) freq.put(b[i].val, 0);
				freq.put(b[i].val, freq.get(b[i].val)+1);
				continue;
			}
			long fr = freq.get(b[i].val+1);
//			System.out.println(i + " " + b[i].val + " " + fr);
			res = add(res, (fr*(b[i].val+1)) - (fr*b[i].val));
//			res += (fr*(b[i].val+1)) - (fr*b[i].val);
			if(!freq.containsKey(b[i].val)) freq.put(b[i].val, 0);
			freq.put(b[i].val, freq.get(b[i].val)+1);
 		}

		out.println(res);

		out.close();
	}

	BigInteger add (BigInteger a, long b) {
		BigInteger res = a.add(BigInteger.valueOf(b));
		return res;
	}

	BigInteger sub (BigInteger a, long b) {
		BigInteger res = a.subtract(BigInteger.valueOf(b));
		return res;
	}

	class Pair implements Comparable<Pair> {
		int val, id;
		Pair (int a, int b) {
			val = a;
			id = b;
		}

		public int compareTo (Pair o) {
			if(val == o.val) return Integer.compare(id, o.id);
			return Integer.compare(o.val, val);
		}
	}

	class Fenwick_Tree {

		long[] bit;
		int n;

		public Fenwick_Tree(int a) {
			n = a + 1;
			bit = new long[n];
		}

		//Remember that when querying a sum to query the 1-based index of the value.

		void update (int index, long val) {
			while(index < n) {
				bit[index] += val;
				index += (index & (-index));
			}
		}

		long sum (int index) {
			long sum = 0;
			while(index > 0) {
				sum += bit[index];
				index -= (index & (-index));
			}
			return sum;
		}
	}

	void sort (int[] a) {
		int n = a.length;
		for(int i = 0; i < 1000; i++) {
			Random r = new Random();
			int x = r.nextInt(n), y = r.nextInt(n);
			int temp = a[x];
			a[x] = a[y];
			a[y] = temp;
		}
		Arrays.sort(a);
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				//				br = new BufferedReader(new FileReader("cases.in"));
				st = new StringTokenizer("");
			} catch (Exception e){e.printStackTrace();}
		}
		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}
		public int nextInt() {return Integer.parseInt(next());}
		public long nextLong() {return Long.parseLong(next());}
		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			try {line = br.readLine();}
			catch (Exception e) {e.printStackTrace();}
			return line;
		}
		public Integer[] nextIntegerArray(int n) {
			Integer[] a = new Integer[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		public char[] nextCharArray() {return nextLine().toCharArray();}
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.HashMap;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            BigInteger ans = new BigInteger("0");
            long val, index, index1, index2;
            long sum[] = new long[n];
            val = in.scanInt();
            HashMap<Long, Integer> hs = new HashMap<>();
            hs.put(val, 1);
            sum[0] = val;
            for (int i = 1; i < n; i++) {
                val = in.scanInt();
                sum[i] += sum[i - 1];
                sum[i] += val;
                if (!hs.containsKey(val)) hs.put(val, 0);
                hs.put(val, hs.get(val) + 1);

                ans = ans.add(BigInteger.valueOf(((i + 1) * val) - sum[i]));
                index = (hs.containsKey(val + 1)) ? hs.get(val + 1) : 0;
                index1 = (hs.containsKey(val - 1)) ? hs.get(val - 1) : 0;
                index2 = (hs.containsKey(val)) ? hs.get(val) : 0;
                ans = ans.subtract(BigInteger.valueOf(((index + index1 + index2) * val) - ((index * (val + 1)) + (index1 * (val - 1)) + (index2 * (val)))));
            }
            out.println(ans);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


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]);
		}
	}
}


/*
 * PDPM IIITDM Jabalpur
 * Asutosh Rana
 */

import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{
    long MOD = 1000000007;
    InputReader in;BufferedReader br;PrintWriter out;
    public static void main (String[] args) throws java.lang.Exception
    {
        Main solver = new Main();
        solver.in = new InputReader(System.in);
        solver.br = new BufferedReader(new InputStreamReader(System.in));
        solver.out = new PrintWriter(System.out);
        solver.solve();
        solver.out.flush();
        solver.out.close();
    }

    public void solve(){

        int tc = 1;//in.readInt();

        for(int cas=1;cas<=tc;cas++){
            int N = in.readInt();
            int[] A = new int[N];
            in.readInt(A);

            HashMap<Integer, Integer> H = new HashMap<>();
            long sum = A[0], count = 1;
            BigInteger B = BigInteger.ZERO;
            H.put(A[0], 1);
            for(int i=1;i<N;i++){
                // res = res + (count*A[i] - sum);
                B = B.add(BigInteger.valueOf(count*A[i]-sum));
                if(!H.containsKey(A[i]))
                    H.put(A[i], 0);
                H.put(A[i], H.get(A[i])+1);

                if(H.containsKey(A[i]-1)){
                    int k = H.get(A[i]-1);
                    // res = res + (k*(A[i]-1) - k*A[i]);
                    B = B.add(BigInteger.valueOf((k*(A[i]-1) - k*A[i])));
                }
                if(H.containsKey(A[i]+1)){
                    int k = H.get(A[i]+1);
                    B = B.add(BigInteger.valueOf((k*(A[i]+1) - k*A[i])));
                    // res = res + (k*(A[i]+1) - k*A[i]);
                }
                // out.println(res);
                sum+=A[i];count++;
            }
            // out.println("-1");
            out.println(B);

        }

    }

}

class InputReader{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream){this.stream = stream;}
    public int read(){
        if (numChars==-1) throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try {numChars = stream.read(buf);}
            catch (IOException e){throw new InputMismatchException();}
            if(numChars <= 0) return -1;
        }
        return buf[curChar++];
    }

    public int readInt(){
        int c = read();
        while(isSpaceChar(c)) c = read();
        int sgn = 1;
        if (c == '-') {sgn = -1;c = read();}
        int res = 0;
        do {
            if(c<'0'||c>'9') throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c)); return res * sgn;
    }

    public void readInt(int[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readInt();
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c));
        return res * sgn;
    }

    public void readLong(long[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readLong();
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public char[] readCharA(){
        return readString().toCharArray();
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
        return readString();
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}


import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

    static Map<BigInteger, BigInteger> mp = new HashMap<BigInteger, BigInteger>();

    public static void main(String[] args) {
        mp.clear();
        Scanner cin = new Scanner(new BufferedInputStream(System.in));
        BigInteger n = cin.nextBigInteger();
        BigInteger x = cin.nextBigInteger();
        mp.put(x, BigInteger.ONE);
        BigInteger sum = x;
        BigInteger ans = BigInteger.ZERO;
        for (int i = 2;i <= n.intValue(); i++) {
            x=cin.nextBigInteger();
            BigInteger tmp = x.multiply(BigInteger.valueOf(i-1)).subtract(sum);
            if (mp.containsKey(x.subtract(BigInteger.ONE))) tmp = tmp.subtract(mp.get(x.subtract(BigInteger.ONE)));
            if (mp.containsKey(x.add(BigInteger.ONE))) tmp = tmp.add(mp.get(x.add(BigInteger.ONE)));
            ans = ans.add(tmp);
            sum = sum.add(x);
            BigInteger xx;
            if (mp.containsKey(x)) xx = mp.get(x);
            else xx = BigInteger.ZERO;
            mp.put(x, xx.add(BigInteger.ONE));
        }
        System.out.println(ans);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author darkhan imangaliyev
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            Map<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < n; ++i) {
                if (map.containsKey(a[i])) {
                    map.put(a[i], map.get(a[i]) + 1);
                } else {
                    map.put(a[i], 1);
                }
            }
            List<Integer> compressed = new ArrayList<>();
            compressed.add(-1);
            compressed.add(Integer.MAX_VALUE);
            compressed.addAll(map.keySet());
            Collections.sort(compressed);
            //        System.out.println(compressed);
            int N = compressed.size() + 10;
            BIT count = new BIT(N);
            BIT sum = new BIT(N);

            BigInteger ret = BigInteger.ZERO;
            for (int i = n - 1; i >= 0; --i) {
                int l = findLeft(compressed, a[i] - 2);
                int r = findRight(compressed, a[i] + 2);
                long left = sum.sum(0, l);
                long countLeft = count.sum(0, l);
                long right = sum.sum(r, N);
                long countRight = count.sum(r, N);
                //            System.out.println("b[i] = " + b[i]);
                //            System.out.println("l = " + l + ", r = " + r);
                //            System.out.println("left = " + left + ", right = " + right);
                //            System.out.println("countLeft = " + countLeft + ", countRight = " + countRight);
                //            System.out.println();
                long t = (left - countLeft * a[i]) + (right - a[i] * countRight);
                ret = ret.add(BigInteger.valueOf(t));
                int x = Collections.binarySearch(compressed, a[i]);
                sum.update(x, a[i]);
                count.update(x, 1);
            }
            out.println(ret);
        }

        private int findLeft(List<Integer> a, int t) {
            int lo = -1, hi = a.size();
            while (hi - lo > 1) {
                int m = lo + (hi - lo) / 2;
                if (a.get(m) <= t) {
                    lo = m;
                } else {
                    hi = m;
                }
            }
            return lo;
        }

        private int findRight(List<Integer> a, int t) {
            int lo = -1, hi = a.size();
            while (hi - lo > 1) {
                int m = lo + (hi - lo) / 2;
                if (a.get(m) < t) {
                    lo = m;
                } else {
                    hi = m;
                }
            }
            return hi;
        }

        class BIT {
            long[] tree;

            public BIT(int n) {
                tree = new long[n + 1];
            }

            public void update(int x, long d) {
                while (x < tree.length) {
                    tree[x] += d;
                    x += x & -x;
                }
            }

            public long sum(int l, int r) {
                return sum(r) - sum(l - 1);
            }

            public long sum(int x) {
                long sum = 0;
                while (x > 0) {
                    sum += tree[x];
                    x -= x & -x;
                }
                return sum;
            }

        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.math.BigInteger;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];

            BigInteger sum = new BigInteger("0");
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                long tmp = ((long) (2 * i + 1 - n)) * a[i];
                sum = sum.add(BigInteger.valueOf(tmp));
            }

            Map<Integer, Integer> cnt = new HashMap<>();

            for (int i = n - 1; i >= 0; --i) {
                if (cnt.containsKey(a[i] + 1)) {
                    sum = sum.subtract(BigInteger.valueOf(cnt.get(a[i] + 1)));
                }
                if (cnt.containsKey(a[i] - 1)) {
                    sum = sum.add(BigInteger.valueOf(cnt.get(a[i] - 1)));
                }
                if (cnt.containsKey(a[i])) {
                    cnt.put(a[i], cnt.get(a[i]) + 1);
                } else {
                    cnt.put(a[i], 1);
                }
            }

            out.println(sum);
        }

    }
}


import java.io.*;

    import java.math.*;
    import java.util.*;
          public class Main1
           {
            private InputStream is;
            private PrintWriter out;
            static int MOD = (int)(1e9+7);
            ArrayList<Integer>[] amp;
            public static void main(String[] args) throws Exception
            {
                new Thread(null, new Runnable()
                {
                public void run()
                {
                    try {
         } catch (Exception e)
                    {
                        System.out.println(e);
                    }
                }
            }, "1", 1 << 26).start();
                new Main1().soln();
            }
            char ch[][];
            static ArrayList<Integer>[] g;
            static ArrayList<Integer> ar[];
            static long ok[];
            static int phi[]=new int[500005];
            void solve()
            {
            	int n=ni();
                int a[]=na(n);
                long sum=0;
                HashMap<Integer,Integer> hm=new HashMap();
                BigInteger ans=(BigInteger.ZERO);
                int count=0;
                for(int i=n-1;i>=0;i--)
                {
               	 int tmp1=0;
               	 int tmp2=0;
               	 int tmp3=0;
               	 if(hm.containsKey(a[i]))
               		 tmp1=hm.get(a[i]);
               	 if(hm.containsKey(a[i]+1))
               		 tmp2=hm.get(a[i]+1);
               	 if(hm.containsKey(a[i]-1))
               		 tmp3=hm.get(a[i]-1);
               	 long lol=sum;
               	 lol-=((long)tmp1*(long)a[i]);
               	 lol-=((long)tmp2*(long)(a[i]+1));
               	 lol-=((long)tmp3*(long)(a[i]-1));
               	 int fr=(count)-tmp1-tmp2-tmp3;
               	 long fuck=(lol)-((long)fr*(long)a[i]);
               	 ans=ans.add(BigInteger.valueOf(fuck));
               	 if(!hm.containsKey(a[i]))
               		 hm.put(a[i],1);
               	 else
               		 hm.put(a[i],hm.get(a[i])+1);
               	 sum+=(long)a[i];
               	 count++;
               	// System.out.println(ans+" "+tmp1+" "+tmp2+" "+tmp3+" "+lol);
                }
                out.println(ans);
            }
           public static long multiply(long a)
            {
            	return a*10;
            }
            public static long query1(int v,int start,int end,int l,int r,int x)
            {
            	if(r < start || end < l)
                {
                    return Long.MAX_VALUE;
                }
                if(l <= start && end <= r)
                {
                    return (tre[v]);
                }
                int mid = (start + end) / 2;
                long p1 = query1(2*v, start, mid, l, r,x);
                long p2 = query1(2*v+1, mid+1, end, l, r,x);
                return Math.min(p1, p2);
            }
            public static void update1(int v,int tl,int tr,int index,long a2)
            {
            	if(tl==tr)
                {
                    tre[v]=a2;
                }
                else
                {
                    int mid=(tl+tr)/2;
                    if(tl <= index &&index <= mid)
                    {
                        update1(2*v,tl, mid, index, a2);
                    }
                    else
                    {
                        update1(2*v+1,mid+1,tr, index, a2);
                    }
                    tre[v]=(Math.min(tre[2*v],tre[2*v+1]));
                }
            }
			static boolean visited[][];
			static int a[][];
            public static long query(int v,int start,int end,int l,int r,int x)
            {
            	if(r < start || end < l)
                {
                    return 0;
                }
                if(l <= start && end <= r)
                {
                    return (tre[v]);
                }
                int mid = (start + end) / 2;
                long p1 = query(2*v, start, mid, l, r,x);
                long p2 = query(2*v+1, mid+1, end, l, r,x);
                return Math.max(p1, p2);
            }
            public static void update(int v,int tl,int tr,int index,long a2)
            {
            	if(tl==tr)
                {
                    tre[v]=a2;
                }
                else
                {
                    int mid=(tl+tr)/2;
                    if(tl <= index &&index <= mid)
                    {
                        update(2*v,tl, mid, index, a2);
                    }
                    else
                    {
                        update(2*v+1,mid+1,tr, index, a2);
                    }
                    tre[v]=(Math.max(tre[2*v],tre[2*v+1]));
                }
            }
            static long tre[]=new long[400005];
          /* public static int find(int v,int start,int end,int l,int r)
            {
                if(r < start || end < l)
                {
                    return Integer.MIN_VALUE;
                }
                if(l <= start && end <= r)
                {
                    return (tre[v]);
                }
                int mid = (start + end) / 2;
                int p1 = find(2*v, start, mid, l, r);
                int p2 = find(2*v+1, mid+1, end, l, r);
                return Math.max(p1, p2);
            }
            static int tre[]=new int[4000005];
            public static void Update(int v,int tl,int tr,int index,int val)
            {
                if(tl==tr)
                {
                    tre[v]=val;
                }
                else
                {
                    int mid=(tl+tr)/2;
                    if(tl <= index &&index <= mid)
                    {
                        Update(2*v,tl, mid, index, val);
                    }
                    else
                    {
                        Update(2*v+1,mid+1,tr, index, val);
                    }
                    tre[v]=(Math.max(tre[2*v],tre[2*v+1]));
                }
            }
            */
            boolean isPrime(int x)
                {
                if(x==0||x==1)
                    return false;
                for(int i = 2;i*1L*i<=x;i++) if(x%i==0) return false;
                return true;
            }
            int  p ;
            long modInverse(long a, long mOD2){
                return  power(a, mOD2-2, mOD2);
            }
            long power(long x, long y, long m)
            {
            if (y == 0)
            return 1;
            long p = power(x, y/2, m) % m;
            p = (p * p) % m;

            return (y%2 == 0)? p : (x * p) % m;
            }
            public static long gcd(long a, long b){
                if(b==0) return a;
                return gcd(b,a%b);
            }
            class Pair1 implements Comparable<Pair1>{
                long a;
                long b;
                long c;
                Pair1(long x,long y,long z){
                this.a=x;
                this.b=y;
                this.c=z;
                }
                public int hashCode() {
                    return Objects.hash();
                }

                @Override
                public int compareTo(Pair1 arg0) {
                    return (int)(arg0.c-c);
                }
            }
            long power(long x, long y, int mod){
                long ans = 1;
                while(y>0){
                    if(y%2==0){
                        x = (x*x)%mod;
                        y/=2;
                    }
                    else{
                        ans = (x*ans)%mod;
                        y--;
                    }
                }
                return ans;
            }
            void soln() {
                is = System.in;
                out = new PrintWriter(System.out);
                long s = System.currentTimeMillis();
                solve();
                out.flush();
            }
             private byte[] inbuf = new byte[1024];
            public int lenbuf = 0, ptrbuf = 0;
            private int readByte() {
                if (lenbuf == -1)
                    throw new InputMismatchException();
                if (ptrbuf >= lenbuf) {
                    ptrbuf = 0;
                    try {
                        lenbuf = is.read(inbuf);
                    } catch (IOException e) {
                        throw new InputMismatchException();
                    }
                    if (lenbuf <= 0)
                        return -1;
                }
                return inbuf[ptrbuf++];
            }
            private boolean isSpaceChar(int c) {
                return !(c >= 33 && c <= 126);
            }
            private int skip() {
                int b;
                while ((b = readByte()) != -1 && isSpaceChar(b))
                    ;
                return b;
            }
            private double nd() {
                return Double.parseDouble(ns());
            }
            private char nc() {
                return (char) skip();
            }
            private String ns() {
                int b = skip();
                StringBuilder sb = new StringBuilder();
                while (!(isSpaceChar(b))) {
                    sb.appendCodePoint(b);
                    b = readByte();
                }
                return sb.toString();
            }
            private char[] ns(int n) {
                char[] buf = new char[n];
                int b = skip(), p = 0;
                while (p < n && !(isSpaceChar(b))) {
                    buf[p++] = (char) b;
                    b = readByte();
                }
                return n == p ? buf : Arrays.copyOf(buf, p);
            }
            private int[][] nm(int n, int m) {
                int[][] map = new int[n][m];
                for (int i = 0; i < n; i++)
                {
                    for(int j=0;j<m;j++)
                        map[i][j]=ni();
                }
                return map;
            }
            private int[] na(int n) {
                int[] a = new int[n];
                for (int i = 0; i < n; i++)
                    a[i] = ni();
                return a;
            }
            private int ni() {
                int num = 0, b;
                boolean minus = false;
                while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
                    ;
                if (b == '-') {
                    minus = true;
                    b = readByte();
                }
                while (true) {
                    if (b >= '0' && b <= '9') {
                        num = num * 10 + (b - '0');
                    } else {
                        return minus ? -num : num;
                    }
                    b = readByte();
                }
            }
            private long nl() {
                long num = 0;
                int b;
                boolean minus = false;
                while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
                    ;
                if (b == '-') {
                    minus = true;
                    b = readByte();
                }
                while (true) {
                    if (b >= '0' && b <= '9') {
                        num = num * 10 + (b - '0');
                    } else {
                        return minus ? -num : num;
                    }
                    b = readByte();
                }
            }
            private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
            private void tr(Object... o) {
                if (!oj)
                    System.out.println(Arrays.deepToString(o));
            }
        }


//package educational.round34;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;

public class D {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int[] a = na(n);
		int[] xs = new int[3*n];
		for(int i = 0;i < n;i++){
			xs[3*i] = a[i];
			xs[3*i+1] = a[i]-1;
			xs[3*i+2] = a[i]+1;
		}
		xs = shuffle(xs, new Random());
		int[] imap = shrinkX(xs);

		BigInteger ans = BigInteger.valueOf(0L);

		{
			int[] ft = new int[3*n+3];
			for(int i = 0;i < n;i++){
				int y = Arrays.binarySearch(imap, a[i]);
				int num =
						i - sumFenwick(ft, y + 1) + sumFenwick(ft, y - 2);
				ans = ans.add(BigInteger.valueOf((long)a[i] * num));
				addFenwick(ft, y, 1);
			}
		}

		{
			int[] ft = new int[3*n+3];
			for(int i = n-1;i >= 0;i--){
				int y = Arrays.binarySearch(imap, a[i]);
				int num =
						n-1-i - sumFenwick(ft, y + 1) + sumFenwick(ft, y - 2);
				ans = ans.subtract(BigInteger.valueOf((long)a[i] * num));
				addFenwick(ft, y, 1);
			}
		}
		out.println(ans);
	}

	public static int sumFenwick(int[] ft, int i)
	{
		int sum = 0;
		for(i++;i > 0;i -= i&-i)sum += ft[i];
		return sum;
	}

	public static void addFenwick(int[] ft, int i, int v)
	{
		if(v == 0 || i < 0)return;
		int n = ft.length;
		for(i++;i < n;i += i&-i)ft[i] += v;
	}

	public static int[] shuffle(int[] a, Random gen){ for(int i = 0, n = a.length;i < n;i++){ int ind = gen.nextInt(n-i)+i; int d = a[i]; a[i] = a[ind]; a[ind] = d; } return a; }

	public static int[] shrinkX(int[] a) {
		int n = a.length;
		long[] b = new long[n];
		for (int i = 0; i < n; i++)
			b[i] = (long) a[i] << 32 | i;
		Arrays.sort(b);
		int[] ret = new int[n];
		int p = 0;
		ret[0] = (int) (b[0] >> 32);
		for (int i = 0; i < n; i++) {
			if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) {
				p++;
				ret[p] = (int) (b[i] >> 32);
			}
			a[(int) b[i]] = p;
		}
		return Arrays.copyOf(ret, p + 1);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new D().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.SplittableRandom;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            int[] b = a.clone();
            b = Arrays.copyOf(b, a.length + 2);
            b[a.length] = 0;
            b[a.length + 1] = (int) 2e9;
            ArrayUtils.sort(b);
            b = ArrayUtils.uniqueArray(b);
            SegmentTreeSumL segmentTreeSumL = new SegmentTreeSumL(b.length + 1);
            SegmentTreeSumL size = new SegmentTreeSumL(b.length + 1);
            for (int i = 0; i < n; ++i) {
                segmentTreeSumL.update(Arrays.binarySearch(b, a[i]), a[i]);
                size.update(Arrays.binarySearch(b, a[i]), 1);
            }
            Debug debug = new Debug(out);
            BigInteger sum = new BigInteger("0");
            for (int i = 0; i < n; ++i) {
                segmentTreeSumL.update(Arrays.binarySearch(b, a[i]), -a[i]);
                size.update(Arrays.binarySearch(b, a[i]), -1);
                int indG = ArrayUtils.LowerBound(b, a[i] + 2);
                indG = Math.min(indG, b.length);
                long s1 = size.getRangeSum(indG, b.length);
                long sum1 = segmentTreeSumL.getRangeSum(indG, b.length);
                //debug.tr("1", s1, sum1);
                sum = sum.add(BigInteger.valueOf(sum1 - s1 * a[i]));
                int indL = ArrayUtils.LowerBound(b, a[i] - 1) - 1;
                indL = Math.max(0, indL);
                long s2 = size.getRangeSum(0, indL);
                long sum2 = segmentTreeSumL.getRangeSum(0, indL);
                //debug.tr("2", s2, sum2);
                sum = sum.add(BigInteger.valueOf(sum2 - s2 * a[i]));
            }
            out.println(sum.toString());
        }

    }

    static class ArrayUtils {
        public static int LowerBound(int[] a, int v) {
            int high = a.length;
            int low = -1;
            while (high - low > 1) {
                int mid = (high + low) >>> 1;
                if (a[mid] >= v) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            return high;
        }

        public static int[] sort(int[] a) {
            a = shuffle(a, new SplittableRandom());
            Arrays.sort(a);
            return a;
        }

        public static int[] shuffle(int[] a, SplittableRandom gen) {
            for (int i = 0, n = a.length; i < n; i++) {
                int ind = gen.nextInt(n - i) + i;
                int d = a[i];
                a[i] = a[ind];
                a[ind] = d;
            }
            return a;
        }

        public static int[] uniqueArray(int[] a) {
            int n = a.length;
            int p = 0;
            for (int i = 0; i < n; i++) {
                if (i == 0 || a[i] != a[i - 1]) a[p++] = a[i];
            }
            return Arrays.copyOf(a, p);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class SegmentTreeSumL {
        long[] lazy;
        long[] seg;
        long[] a;
        int size;
        int N;

        public SegmentTreeSumL(long[] a) {
            this.N = a.length;
            size = 4 * N;
            seg = new long[size];
            lazy = new long[size];
            this.a = a;
            build(0, N - 1, 0);
        }

        public SegmentTreeSumL(int n) {
            this.N = n;
            size = 4 * N;
            seg = new long[size];
            lazy = new long[size];
        }

        private void build(int s, int e, int c) {
            if (s == e) {
                seg[c] = a[s];
                return;
            }
            int m = (s + e) >>> 1;
            build(s, m, 2 * c + 1);
            build(m + 1, e, 2 * c + 2);
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

        public void update(int index, int value) {
            update(0, N - 1, 0, index, value);
        }

        private void update(int s, int e, int c, int index, int value) {
            if (s == e) {
                seg[c] += value;
                return;
            }
            int m = (s + e) >>> 1;
            if (index <= m) {
                update(s, m, 2 * c + 1, index, value);
            } else {
                update(m + 1, e, 2 * c + 2, index, value);
            }
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

        public long getRangeSum(int l, int r) {
            return getRangeSum(0, N - 1, 0, l, r);
        }

        private long getRangeSum(int s, int e, int c, int l, int r) {
            if (s > e || l > r || l > e || r < s) return 0;
            if (lazy[c] != 0) {
                if (s != e) {
                    lazy[2 * c + 1] += lazy[c];
                    lazy[2 * c + 2] += lazy[c];
                }
                seg[c] += (e - s + 1) * (1L) * lazy[c];
                lazy[c] = 0;
            }
            if (s == e) {
                return seg[c];
            }
            if (s >= l && e <= r) {
                return seg[c];
            }
            int m = (s + e) >>> 1;
            return getRangeSum(s, m, 2 * c + 1, l, r)
                    + getRangeSum(m + 1, e, 2 * c + 2, l, r);
        }

    }

    static class Debug {
        PrintWriter out;
        boolean oj;

        public Debug(PrintWriter out) {
            oj = System.getProperty("ONLINE_JUDGE") != null;
            this.out = out;
        }

    }
}


import java.math.BigInteger;
import java.util.*;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class D {
  public static void main(String[] args) {
    init();

    int n = in.nextInt();

    long total = 0L;

    int arr[] = new int[n+5];

    Map<Integer, Integer> freq = new HashMap<>();
    Map<Integer, Integer> kiri = new HashMap<>();

    for (int i = 1; i <= n; ++i){
     arr[i] = in.nextInt();
      if (freq.containsKey(arr[i])) {
        freq.put(arr[i], freq.get(arr[i])+1);
      } else {
        freq.put(arr[i], 1);
        kiri.put(arr[i], 0);
      }
      total += (long)arr[i];
    }

    BigInteger ans = BigInteger.valueOf(0L);

    for (int i = 1; i <= n - 1; ++i) {
      kiri.put(arr[i], kiri.get(arr[i])+1);
      total -= arr[i];

      int cnt_kanan = n - i;
      long temp = total;
      int cnt_sama = freq.get(arr[i]) - kiri.get(arr[i]);
      temp -= (cnt_sama)*(long)arr[i];
      cnt_kanan -= (cnt_sama);
      if (freq.containsKey(arr[i]-1)) {
        int cnt_kurang = freq.get(arr[i]-1) - kiri.get(arr[i]-1);
        cnt_kanan -= cnt_kurang;
        temp -= (long) cnt_kurang * (long)(arr[i]-1);
      }
      if (freq.containsKey(arr[i]+1)) {
        int cnt_lebih = freq.get(arr[i]+1) - kiri.get(arr[i]+1);
        cnt_kanan -= cnt_lebih;
        temp -= (long)(cnt_lebih) * (long)(arr[i]+1);
      }
      temp -= (long)cnt_kanan * (long)arr[i];
      ans = ans.add(BigInteger.valueOf(temp));
    }

    out.println(ans.toString());
    out.close();
  }

  /* PrintWriter and BufferedReader Template from Codeforces */
  public static MyScanner in;
  public static PrintWriter out;

  public static void init() {
    in = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
  }

  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D903 solver = new D903();
        solver.solve(1, in, out);
        out.close();
    }

    static class D903 {
        int N;
        long ripple;
        BigInteger tot;
        long[] nums;
        BigInteger[] cs;

        public void solve(int testNumber, FastScanner s, PrintWriter out) {
            N = s.nextInt();
            nums = s.nextLongArray(N);
            tot = new BigInteger("0");
            cs = new BigInteger[N + 1];
            cs[0] = new BigInteger("0");
            ripple = 0;
            for (int i = 1; i <= N; i++)
                cs[i] = cs[i - 1].add(new BigInteger("" + nums[i - 1]));

            for (int i = 1; i <= N; i++) {
                long cur = nums[i - 1];
//            out.printf("%d: cs %d, minus %d%n", i, (cs[N] - cs[i]), cur * (N - i));
                tot = tot.add(cs[N].subtract(cs[i])).subtract(new BigInteger("" + (cur * (N - i))));
            }

            HashMap<Long, Integer> seen = new HashMap<>();
            for (long i : nums) {
                Integer lo = seen.get(i - 1);
                Integer hi = seen.get(i + 1);
                if (lo != null)
                    tot = tot.subtract(new BigInteger("" + lo));
                if (hi != null)
                    tot = tot.add(new BigInteger("" + hi));

                if (!seen.containsKey(i))
                    seen.put(i, 0);
                seen.put(i, seen.get(i) + 1);
            }

            out.println(tot);
        }

    }

    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long[] nextLongArray(int N) {
            long[] ret = new long[N];
            for (int i = 0; i < N; i++)
                ret[i] = this.nextLong();
            return ret;
        }

    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class d {

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        long[] arr = new long[n];//in.nextLongArray(n);
        for (int i = 0; i < n; i++) {
            //if (i < n / 2) arr[i] = 1;
            //else arr[i] = 1000000000;
            arr[i] = in.nextLong();
        }
        long sum = 0;
        long count = 0;

        TreeSet<Long> ts = new TreeSet<>();
        ts.add(1L);
        long oo = 1000000000 + 100;
        ts.add(oo);
        for (long a : arr) {
            a += 10;
            ts.add(a);
            ts.add(a - 2);
            ts.add(a + 2);
        }

        long[] inds = new long[ts.size()];
        int idx = 0;
        for (long a : ts) {
            inds[idx++] = a;
        }

        SuperBIT bit1 = new SuperBIT(inds);
        SuperBIT bit2 = new SuperBIT(inds);
        BigInteger ans = BigInteger.valueOf(0);

        for (long a : arr) {
            a += 10;

            long countLess = bit1.queryCompr(1, a - 2);
            long sumLess = bit2.queryCompr(1, a - 2);

            long countMore = bit1.queryCompr(a + 2, oo);
            long sumMore = bit2.queryCompr(a  + 2, oo);

            //System.out.println(a + "  " + countLess + "  " + sumLess + "  " + countMore + "  " + sumMore);
            bit1.updateCompr(a, 1);
            bit2.updateCompr(a, a);

            long tmp = 0;
            tmp += countLess * a - sumLess;
            tmp -= sumMore - countMore * a;
            ans = ans.add(BigInteger.valueOf(tmp));
        }

        out.println(ans);

        out.close();
    }
static class SuperBIT {
  long[] dataMul, dataAdd;
  SuperBIT(int n) {
    dataMul = new long[n];
    dataAdd = new long[n];
  }
  void update(int left, int right, long val) {
    internalUpdate(left, val, -val * (left-1));
    internalUpdate(right, -val, val * right);
  }
  void internalUpdate(int at, long mul, long add) {
    while (at < dataMul.length) {
      dataMul[at] += mul;
      dataAdd[at] += add;
      at |= (at + 1);
    }
  }
  long query(int at) {
    long mul = 0;
    long add = 0;
    int start = at;
    while(at >= 0) {
      mul += dataMul[at];
      add += dataAdd[at];
      at = (at & (at + 1)) -1;
    }
    return mul * start + add;
  }
  long query(int left, int right) {
    if (left > right) {
      int temp = left;
      left = right;
      right = temp;
    }
    return query(right) - (left > 0 ? query(left-1) : 0);
  }
  long[] indices; // Used for compressed BIT
  // Compressed BIT constructor
  // A BIT that only stores the values that will be updated.
  // indices is a sorted array of all the unique indices
  // that would be used for this BIT.
  public SuperBIT(long[] indices) {
    this.indices = indices;
    dataMul = new long[indices.length];
    dataAdd = new long[indices.length];
  }

  // Search for the index in the array. If the index was not found,
  // return the first index lower than the search index.
  int binSearch(long ind) {
    int low = 0;
    int high = dataMul.length-1;
    while(low < high) {
      int mid = (low + high+1)/2;
      if(indices[mid] == ind)
        return mid;
      else if(indices[mid] < ind)
        low = mid;
      else if(indices[mid] > ind)
        high = mid-1;
    }
    if(indices[low] > ind)
      --low;
    return low;
  }

  // Read the largest index less than or equal to the given index.
  long queryCompr(long index) {
    return query(binSearch(index));
  }
  long queryCompr(long left, long right) {
    return query(binSearch(left), binSearch(right));
  }
  // Update a specific index by a value. If the index is not in this
  // compressed BIT, the index below will be updated.
  void updateCompr(long index, long val) {
    int ind = binSearch(index);
    update(ind, ind, val);
  }
  void updateCompr(long left, long right, long val) {
    update(binSearch(left), binSearch(right), val);
  }
}
    static Random rand = new Random();
    static void sort(int[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void sort(long[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            long tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static void sort(double[] a) {
        int n = a.length;
        for (int i = a.length - 1; i > 0; i--) {
            int j = rand.nextInt(i + 1);
            double tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }
    static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    static long[] eEuclid(long a, long b) {
        if (b == 0) return new long[] { a, 1, 0 };
        long[] ans = eEuclid(b, a % b);
        long temp = ans[1] - ans[2] * (a / b);
        ans[1] = ans[2];  ans[2] = temp;
        return ans;
    }
    static long modInverse(long a, long m) {
        return ((eEuclid(a, m)[1] % m) + m) % m;
    }
    static class IntList {
        static int[] EMPTY = {};
        int[] a = EMPTY;
        int n = 0;
        void add(int v) {
            if (n >= a.length)
                a = Arrays.copyOf(a, (n << 2) + 8);
            a[n++] = v;
        }
        int get(int idx) {
            return a[idx];
        }
        int size() {
            return n;
        }
    }
    static class DisjointSet {
        int[] s, r;
	public DisjointSet(int n) {
            s = new int[n]; r = new int[n];
            for (int i = 0; i < n; i++) s[i] = i;
        }
        public int find(int i) { return s[i] == i ? i : (s[i] = find(s[i])); }
	public void union(int a, int b) {
            if(r[a = find(a)] == r[b = find(b)]) r[a]++;
            if(r[a] >= r[b]) s[b] = a; else s[a] = b;
        }
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if(st.hasMoreTokens())
                return st.nextToken();
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        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());
        }
        public int[] nextOffsetIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt() - 1;
            return arr;
        }
        public int[] nextIntArray(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt();
            return arr;
        }
        public int[][] nextIntArray(int n, int m) throws IOException {
            int[][] arr = new int[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextInt();
            return arr;
        }
        public long[] nextLongArray(int n) throws IOException {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextLong();
            return arr;
        }
        public long[][] nextLongArray(int n, int m) throws IOException {
            long[][] arr = new long[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextLong();
            return arr;
        }
        public double[] nextDoubleArray(int n) throws IOException {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextDouble();
            return arr;
        }
        public double[][] nextDoubleArray(int n, int m) throws IOException {
            double[][] arr = new double[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    arr[i][j] = nextDouble();
            return arr;
        }
        public char[][] nextCharArray(int n, int m) throws IOException {
            char[][] arr = new char[n][];
            for (int i = 0; i < n; i++)
                arr[i] = next().toCharArray();
            return arr;
        }
    }
}


/**
 * Created by Aminul on 12/12/2017.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CF903D {
    public static void main(String[] args) throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        int a[] = new int[n+1];
        int b[] = new int[n+1];
        TreeSet<Integer> set = new TreeSet<>();
        for(int i = 1; i <= n; i++){
            a[i] = in.nextInt();
            set.add(a[i]);
        }
        int k = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        int last = set.first();
        for(int i : set){
            if(i - last > 1) k += 2;
            else k += 1;
            map.put(i, k);
            last = i;
        }

        for(int i = 1; i <= n; i++){
            b[i] = map.get(a[i]);
        }

        BinaryIndexTree bit = new BinaryIndexTree(k);
        BinaryIndexTree freq = new BinaryIndexTree(k);

        BigInteger res = BigInteger.ZERO;

        for(int i = n; i >= 1; i--){
            long l = bit.query(1, b[i]-2), r = bit.query(b[i]+2, k);
            long lf = freq.query(1, b[i]-2), rf = freq.query(b[i]+2, k);

            res = res.add(BigInteger.valueOf(r));
            res = res.add(BigInteger.valueOf(l));
            res = res.subtract(BigInteger.valueOf(rf*a[i]));
            res = res.subtract(BigInteger.valueOf(lf*a[i]));

            bit.add(b[i], a[i]);
            freq.add(b[i], 1);
        }

        pw.println(res);

        pw.close();
    }

    static class BinaryIndexTree{
        public long bit[];
        int n, len;

        public BinaryIndexTree(int nn){
            n = nn;
            bit = new long[n+1];
            len = bit.length;
        }

        public void add(int index, long value){
            for(; index < len;index = index + ( index & -index)){
                bit[index] += value;
            }
        }

        public long sum(int index){
            if(index <= 0) return 0;
            long sum = 0;
            for(; index > 0;index = index - (index & -index)){
                sum += bit[index];
            }
            return sum;
        }

        public long query(int i, int j){
            if(j < i) return 0;
            return sum(j) - sum(i-1);
        }

    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;
        static final int ints[] = new int[128];

        public FastReader(InputStream is) {
            for (int i = '0'; i <= '9'; i++) ints[i] = i - '0';
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
       /* public char nextChar() {
            return (char)skip();
        }*/

        public char[] next(int n) {
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        /*private char buff[] = new char[1005];
        public char[] nextCharArray(){
            int b = skip(), p = 0;
            while(!(isSpaceChar(b))){
                buff[p++] = (char)b;
                b = readByte();
            }
            return Arrays.copyOf(buff, p);
        }*/
    }
}


import java.io.BufferedReader;
import java.io.File;
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.HashMap;
import java.util.StringTokenizer;

public class D
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		BigInteger ans = BigInteger.ZERO;
		int n = sc.nextInt();
		int arr[] = new int[n];
		long cum[] = new long[n];

		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();

//		int n=(int)2e5;
//		for(int i=0;i<n;i++){
//			arr[i]=1;
//			if(i>n/2)
//				arr[i]=(int)1e9;
//		}

		for (int i = 0; i < cum.length; i++)
		{
			cum[i] = arr[i];
			if(i > 0)
				cum[i] += cum[i-1];
		}

		for (int i = 0; i < n; i++)
			ans = ans.add(BigInteger.valueOf((1l*(i+1)*arr[i] - cum[i])));

		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++)
		{
			ans =  ans.subtract(BigInteger.valueOf(map.getOrDefault(arr[i]-1, 0)));
			ans = ans.add(BigInteger.valueOf(map.getOrDefault(arr[i]+1, 0)));
			map.put(arr[i], map.getOrDefault(arr[i], 0)+1);
		}

		pw.println(ans);
		pw.flush();
		pw.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s)
		{
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException
		{
			br = new BufferedReader(new FileReader(new File((s))));
		}

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

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

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

		public String nextLine() throws IOException
		{
			return br.readLine();
		}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else
				{
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException
		{
			return br.ready();
		}
	}
}


import java.math.BigDecimal;
import java.util.*;
import java.math.BigInteger;
public class Main {
    static Long[] a = new Long[205000];
    static Long[] postfix=new Long[205000];
    static HashMap<Long,Long> check=new HashMap<Long,Long>();
    public static void main(String args[]) {
        Scanner cin = new Scanner(System.in);
        long k, j, p,sum,equal,bigone,lessone,cnt;
        BigInteger ans;
        int i,n;
        while (cin.hasNext()) {
            n=cin.nextInt();
            check.clear();
            for(i=1;i<=n;i++)
            {
                a[i]=cin.nextLong();
            }
            postfix[n+1]=0L;
            for(i=n;i>=1;i--) {
                postfix[i] = postfix[i + 1] + a[i];
                if (check.containsKey(a[i]) == true) {
                    Long v = check.get(a[i]);
                    v += 1;
                    check.put(a[i], v);
                }
                else
                    check.put(a[i],1L);
            }
            ans=BigInteger.ZERO;
            for(i=1;i<n;i++){
                Long v=check.get(a[i]);
                v--;
                check.put(a[i],v);
                equal=check.get(a[i]);
                bigone=0L;
                lessone=0L;
                if(check.containsKey(a[i]+1L)==true)
                bigone=check.get(a[i]+1L);
                if(check.containsKey(a[i]-1L)==true)
                lessone=check.get(a[i]-1L);
                sum=postfix[i]-bigone*(a[i]+1L)-lessone*(a[i]-1L)-equal*a[i]-a[i];
                cnt=n-i-bigone-lessone-equal;
                ans=ans.add(BigInteger.valueOf(a[i]*cnt).subtract(BigInteger.valueOf(sum)));
            }
            System.out.println(ans.multiply(BigInteger.valueOf(-1)));
        }
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    protected static final double EPS = 1e-11;
    private static StreamTokenizer in;
    private static Scanner ins;
    private static PrintWriter out;
    protected static final Double[] BAD = new Double[]{null, null};
    private boolean[][] layouts;
    private int c;
    private int b;
    private int a;
    private String word;

    public static void main(String[] args) {

        try {
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            ins = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
            out = new PrintWriter(System.out);
            try {
                if (System.getProperty("xDx") != null) {
                    in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
                    ins = new Scanner(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                }
            } catch (Exception e) {
                in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
                ins = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }
            new Main().run();
        } catch (Throwable e) {
//            e.printStackTrace();
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    private int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    private long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    private double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    private String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    private char nextChar() throws IOException {
        in.nextToken();
        return (char) in.ttype;
    }

    private void run() throws Exception {
        /*int t = nextInt();
        for (int i = 0; i < t; i++) {
            out.printf(Locale.US, "Case #%d: %d\n", i + 1, solve());
        }*/
        solve();
    }

    private void solve() throws IOException {
        int n = ins.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = ins.nextInt();
        }

        Map<Long, Integer> map = new HashMap<>();

        BigInteger res = BigInteger.ZERO;
        long sum = 0;
        long amount = 0;

        for (int i = n - 1; i >= 0; i--) {
            long cur = a[i];
            Pair same = getZeroAmount(cur, map);

            res = res.add(BigInteger.valueOf((sum - same.sum) - cur * (amount - same.amount)));
            amount++;
            sum += cur;
            map.put(cur, map.getOrDefault(cur, 0) + 1);
        }

        out.println(res);
    }

    class Pair {
        long amount;
        long sum;

        public Pair(long amount, long sum) {
            this.amount = amount;
            this.sum = sum;
        }
    }

    private Pair getZeroAmount(long cur, Map<Long, Integer> map) {
        long amount = 0;
        long sum = 0;
        for (long i = cur - 1; i <= cur + 1; i++) {
            long amountI = map.getOrDefault(i, 0);
            amount += amountI;
            sum += amountI * i;
        }
        return new Pair(amount, sum);
    }

    private List<Integer> iterate(List<Integer> a) {
        ArrayList<Integer> b = new ArrayList<>();
        int prev = -1;
        for (int x : a) {
            if (x == prev) {
                b.add(x);
            } else {
                prev = x;
            }
        }
        return b;
    }

    private long gcd(long a, long b) {
        while (a > 0 && b > 0) {
            long k = a % b;
            a = b;
            b = k;
        }

        return a | b;
    }

}


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.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

	static void insert(TreeMap<Integer, Integer>map,int v,int d)
	{
		if(!map.containsKey(v))map.put(v, 0);
		map.put(v, d+map.get(v));
		if(map.get(v)==0)map.remove(v);
	}

	static void cut(TreeSet<Integer> cuts, TreeMap<Integer, Integer>segments,int v)
	{
		int upper = cuts.higher(v) , lower = cuts.lower(v);
		insert(segments, upper-lower, -1);
		insert(segments, upper-v, 1);
		insert(segments, v-lower, 1);
		cuts.add(v);
	}

	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt(), h = sc.nextInt() , n = sc.nextInt();
		TreeSet<Integer> vCuts = new TreeSet<>() , hCuts = new TreeSet<>();
		TreeMap<Integer, Integer> vSegments = new TreeMap<>() , hSegments = new TreeMap<>();
		vCuts.add(0);vCuts.add(w);
		hCuts.add(0);hCuts.add(h);
		insert(vSegments, w, 1);
		insert(hSegments, h, 1);
		StringBuilder sb = new StringBuilder();
		while(n-->0)
		{
			if(sc.next().equals("H"))
				cut(hCuts, hSegments, sc.nextInt());
			else
				cut(vCuts, vSegments, sc.nextInt());
			sb.append(1l*hSegments.lastKey() * vSegments.lastKey() + "\n");
		}
		System.out.println(sb);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String file) throws FileNotFoundException {br = new BufferedReader(new FileReader(file));}
		public String next() throws IOException {while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
		public int[] nexIntArray() throws Throwable {
			st = new StringTokenizer(br.readLine());
			int[] a = new int[st.countTokens()];
			for (int i = 0; i < a.length; i++)a[i] = nextInt();
			return a;
		}
		public boolean ready() throws IOException {return br.ready();}
	}
}


import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }

        for (int i = 0; i < n; i++)
            a[i] *= -1;
        Arrays.sort(a);
        for (int i = 0; i < n; i++)
            a[i] *= -1;

        int ans = 0;
        int sum1 = 0;
        for (int i = 0; i < n; i++) {
            sum1 += a[i];
            sum -= a[i];
            ans++;
            if (sum1 > sum)
                break;
        }

        pw.print(ans);
        pw.close();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class A {

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        Arrays.sort(a);
        int sum = 0;
        for (int i = a.length - 1; i >= 0; i--) {
            sum += a[i];
            int k = 0;
            for (int j = 0; j < i; j++)
                k += a[j];
            if (sum > k) {
                pl(a.length - i);
                return;
            }
        }
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Test {
	static BufferedReader reader;
	static StringTokenizer tokenizer;
	static PrintWriter writer;

	static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	static String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
		tokenizer = null;
		writer = new PrintWriter(System.out);
		solve();
		reader.close();
		writer.close();
	}

	private static void solve() throws IOException {
		int n = nextInt();
		int[] mas = new int[n];
		int sum=0;
		for(int i=0;i<n;i++)
		{
			mas[i]=nextInt();
			sum+=mas[i];
		}
		Arrays.sort(mas);
		int cs=0;
		int res=0;
		for(int i=n-1;i>=0;i--)
		{
			cs+=mas[i];
			sum-=mas[i];
			res++;
			if(cs>sum)
				break;
		}
		writer.println(res);
	}
}


import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), sum = 0;

		Integer[] A = new Integer[n];

		for (int i = 0 ; i < n ; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}

		Arrays.sort(A, Collections.reverseOrder());

		int c = 0, ans = 0;

		while (ans <= sum) {
			ans += A[c];
			sum -= A[c];
			c++;
		}

		System.out.println(c);
	}
}


import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;

public class a111 {
    public static void debug(Object... obs) {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n=sc.nextInt();
        int[]a=new int[n];

        int su=0;
        for(int i=0;i<n;i++)
        {
            a[i]=-sc.nextInt();
            su+=-1*a[i];
        }
        Arrays.sort(a);

        int ss=0;
        for(int i=0;i<n;i++)
        {
            ss+=-1*a[i];
            su-=-1*a[i];
            if(ss > su)
            {
                System.out.println(i+1);
                return;
            }
        }

    }
}