#include <bits/stdc++.h>
using namespace std;
const int N = 1e6, inf = 1e9;
const long long mod = 1e9 + 7;
long long mt[2003][2003];
long long big(int b, int p, int m = mod) {
  int ret = 1;
  while (p) {
    if (p & 1) ret = (1LL * ret * b) % m;
    b = (1LL * b * b) % m;
    p /= 2;
  }
  return ret * 1LL;
}
long long fac[N + 2], aa[N + 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fac[0] = 1;
  for (int i = 1; i <= N; i++) fac[i] = (fac[i - 1] * i) % mod;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> aa[i];
  long long ans = 0;
  for (int i = 2; i < n; i++) {
    long long inv = (1LL * i * (i - 1)) % mod;
    inv = big(inv, mod - 2);
    mt[1][i] = (fac[n - 1] * inv) % mod;
    ans = (ans + (aa[i] - aa[1]) * mt[1][i]) % mod;
  }
  mt[1][n] = fac[n - 2];
  ans = (ans + (aa[n] - aa[1]) * mt[1][n]) % mod;
  for (int i = 2; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      mt[i][j] = mt[i - 1][j - 1];
      ans = (ans + (aa[j] - aa[i]) * mt[i][j]) % mod;
    }
    mt[i][n] = mt[i - 1][n] + mt[i - 1][n - 1];
    ans = (ans + (aa[n] - aa[i]) * mt[i][n]) % mod;
  }
  cout << ans << endl;
  return 0;
}
