#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll mod(ll A, ll M) { return (A % M + M) % M; }
const ll INF = 1LL << 60;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll divceil(ll A, ll B) { return (A + (B - 1)) / B; }
ll myctoi(char C) { return C - '0'; }
char myitoc(ll N) { return '0' + N; }
class combination {
 public:
  vector<ll> fac, finv, inv, facac;
  combination(ll M) {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);
    for (ll i = 2; i < M; i++) {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }
  ll P(ll N, ll K) {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }
  ll C(ll N, ll K) {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }
  ll H(ll N, ll K) { return C(N + K - 1, K); }
};
int main() {
  ll N;
  cin >> N;
  ll M = N - 1;
  vector<ll> X(N);
  for (ll i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  if (N > 2010) return 0;
  combination com(N + 10);
  ll ans = 0;
  for (ll i = M, j = 1; i >= 1; i--, j++) {
    ll tmp = i * com.fac.at(i - 1);
    for (ll k = i - 2; k >= 0; k--) {
      tmp += (k + 1) *
             (com.fac.at(k) * com.fac.at(i) % MOD * com.finv.at(k + 2) % MOD) %
             MOD;
      tmp %= MOD;
    }
    tmp *= com.fac.at(M) * com.finv.at(i) % MOD;
    tmp %= MOD;
    ans += tmp * (X.at(i) - X.at(i - 1)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
