#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long b, long long m) {
  if (b == 0) return 1;
  long long ret;
  if (b % 2 == 0) {
    long long t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    long long t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}
int main() {
  long long n;
  cin >> n;
  assert(n <= 2000);
  vector<long long> x(n);
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
  }
  COMinit();
  long long ans = 0;
  for (long long i = 1; i < n + 1; i++)
    for (long long j = i + 1; j < n + 1; j++) {
      long long cnt = (j != n) ? fac[j - i - 1] * COM(n - 1, j - i + 1) % MOD *
                                     fac[n - 1 - (j - i + 1)] % MOD
                               : fac[n - 1 - i] * COM(n - 1, i - 1) % MOD *
                                     fac[i - 1] % MOD;
      ans += (x[j - 1] - x[i - 1]) * cnt % MOD;
      ans %= MOD;
    }
  cout << ans << endl;
}
