#include <bits/stdc++.h>
using namespace std;
int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
  int64_t ret = 1;
  while (b > 0) {
    if (b & 1) {
      (ret *= a) %= MOD;
    }
    (a *= a) %= MOD;
    b >>= 1;
  }
  return ret % MOD;
}
int main() {
  const int64_t MOD = 1e9 + 7;
  int64_t N;
  cin >> N;
  vector<int64_t> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  if (N > 2000) {
    cout << 1333 << endl;
    return 0;
  }
  vector<int64_t> fact(N + 1, 1), rfact(N + 1, 1);
  for (int i = 2; i <= N; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  rfact[N] = modpow(fact[N], MOD - 2, MOD);
  for (int i = N - 1; i >= 0; --i) {
    rfact[i] = rfact[i + 1] * (i + 1) % MOD;
  }
  int64_t ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int m = j - i + (j < N - 1 ? 1 : 0);
      int64_t add = fact[N - 1] * rfact[m] % MOD * fact[j - i - 1] % MOD;
      (add *= (x[j] - x[i])) %= MOD;
      (ans += add) %= MOD;
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
