#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
const Int MAX = 200000;
array<Int, MAX> fac, finv, inv;
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;
  }
}
Int 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;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  COMinit();
  int N;
  cin >> N;
  if (N > 2000) return 1;
  vector<Int> X(N);
  for (auto &x : X) cin >> x;
  vector<Int> S(N + 1);
  for (int i = 0; i < N; i++) S[i + 1] = S[i] + X[i];
  vector<Int> move(N);
  for (int i = 1; i <= N - 2; i++) {
    for (int j = 0; j + i < N - 1; j++) {
      move[i] += X[j + i] - X[j];
      move[i] %= MOD;
    }
  }
  Int ans = 0;
  for (int i = 1; i <= N - 2; i++) {
    for (int j = 0; j <= N - 2 - i; j++) {
      Int t = COM(N - 2 - i, j) * fac[j + i - 1] % MOD * move[i] % MOD *
              fac[N - 1 - i - j] % MOD;
      ans += t;
      ans %= MOD;
    }
  }
  for (int i = 1; i <= N - 1; i++) {
    for (int j = 0; j <= N - 1 - i; j++) {
      Int t = COM(N - 1 - i, j) * fac[j + i - 1] % MOD *
              (X[N - 1] - X[N - 1 - i]) % MOD * fac[N - 1 - i - j] % MOD;
      ans += t;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
