#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  int x[n];
  int N = 1;
  int sum = 0;
  int str;
  int j;
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 1; i < n; i++) N *= i;
  for (int i = 0; i < n - 1; i++) {
    for (j = 1; j < n - 1 - i; j++) {
      str = (x[i + j] - x[i]) * N / j;
      str = str / (j + 1);
      sum += str;
    }
    str = (x[i + j] - x[i]) * N / j;
    sum += str;
  }
  printf("%d", sum);
  return 0;
}
