#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int MAX = 510000;
const ll MOD = 1000000007;
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;
  }
}
void big_case(int N, vector<int> x) {
  ll ans = 0;
  ll sum = x[N - 1];
  for (int i = (N - 2); i >= 0; --i) {
    ans += sum - x[i];
    ans %= mod;
    sum += x[i];
    sum %= mod;
  }
  cout << ans << endl;
}
void short_case(int N, vector<ll> x) {
  ll ans = 0;
  ll sum = 0;
  for (int i = 0; i < (N - 1); ++i) {
    for (int j = (i + 1); j < (N); ++j) {
      int pa = j - i - 1 + 1;
      if (j != N - 1) pa++;
      ll cost = (fac[j - i - 1] * fac[N - 1]) % mod * finv[pa];
      cost %= mod;
      ans += ((x[j] - x[i]) * cost) % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
}
int main() {
  COMinit();
  int N;
  cin >> N;
  vector<ll> x(N);
  for (int i = 0; i < (N); ++i) {
    cin >> x[i];
  }
  short_case(N, x);
  return 0;
}
