#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long inv[200020 + 10], fac[200020 + 10], ifac[200020 + 10];
void setComb() {
  inv[0] = 1;
  inv[1] = 1;
  fac[1] = 1;
  ifac[1] = 1;
  fac[0] = 1;
  ifac[0] = 1;
  for (int i = 2; i < 200020; i++) {
    inv[i] = (-MOD / i) * inv[MOD % i] % MOD;
    fac[i] = fac[i - 1] * i % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
    inv[i] = (inv[i] + MOD) % MOD;
    fac[i] = (fac[i] + MOD) % MOD;
    ifac[i] = (ifac[i] + MOD) % MOD;
  }
  return;
}
long long comb(long long n, long long k) {
  if (n < k || n < 0 || k < 0)
    return 0;
  else
    return ((fac[n] * ifac[k] % MOD * ifac[n - k] % MOD + MOD) % MOD);
}
long long hcomb(long long n, long long r) {
  if (n == 0 && r == 0)
    return 1;
  else if (n < 0 || r < 0)
    return 0;
  else
    return comb(n + r - 1, r - 1);
}
long long num[200020];
int main() {
  int N;
  cin >> N;
  vector<long long> X(N);
  for (int i = 0; i < (N); ++i) cin >> X[i];
  setComb();
  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      long long val = X[j] - X[i];
      long long res = fac[N - 1] * ifac[j - i + 1] % MOD;
      res = res * fac[j - i + 1 - 2] % MOD;
      res = res * val % MOD;
      ans = (ans + res) % MOD;
    }
    long long val = X[N - 1] - X[i];
    long long res = fac[N - 1] * ifac[N - 1 - i] % MOD;
    res = res * fac[N - 1 - i - 1] % MOD;
    res = res * val % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
  return 0;
}
