#include <bits/stdc++.h>
const long INF = (1l << 30);
const long LINF = (1l << 60);
const long MOD = 1000000007;
long N = 100005;
long factorial[100005];
long modinv[100005];
long x[100005];
long ans = 0;
long power(long num1, long num2) {
  if (num2 == 1) {
    return num1 % MOD;
  } else if (num2 % 2) {
    return num1 * power(num1, num2 - 1) % MOD;
  } else {
    long result = power(num1, num2 / 2);
    return result * result % MOD;
  }
}
void nCr_init() {
  factorial[0] = 1;
  factorial[1] = 1;
  for (long i = 2; i <= N; i++) {
    factorial[i] = factorial[i - 1] * i % MOD;
  }
  for (int i = 0; i <= N; i++) {
    modinv[i] = power(factorial[i], MOD - 2);
  }
  for (int i = 0; i <= N; i++) {
    modinv[i] = power(factorial[i], MOD - 2);
  }
}
int main() {
  long n;
  scanf("%ld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%ld", &x[i]);
  }
  nCr_init();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      long res = 0;
      if (j < n - 1) {
        res = (factorial[n - 1] * factorial[j - i - 1]) % MOD;
        res *= modinv[j - i + 1];
        res %= MOD;
      } else {
        res = (factorial[n - 1] * factorial[n - i - 2]) % MOD *
              modinv[n - i - 1] % MOD;
      }
      res *= x[j] - x[i];
      res %= MOD;
      ans += res;
      ans %= MOD;
    }
  }
  printf("%ld\n", ans);
}
