#include <bits/stdc++.h>
using namespace std;
class Combination {
 public:
  long long N;
  long long mod;
  vector<long long> fac;
  vector<long long> finv;
  vector<long long> inv;
  Combination(long long N = 1e6, long long mod = 1e9 + 7)
      : N(N), mod(mod), fac(N + 1), finv(N + 1), inv(N + 1) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i <= N; 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;
    }
  }
  function<long long(long long, long long)> get = [&](long long n,
                                                      long long r) {
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
  };
};
const long long mod = 1e9 + 7;
const long long N = 2005;
long long n, x[N], dp[N][N], C[N][N], F[N], P[N], J[N];
void init() {
  Combination com;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= i; j++) {
      C[i][j] = com.get(i, j);
    }
  }
  F[0] = 1;
  for (long long i = 1; i <= n; i++) F[i] = F[i - 1] * i % mod;
  P[n] = P[n - 1] = 1;
  long long X = 1;
  for (long long i = n - 2; i >= 0; i--) {
    P[i] = P[i + 1] * X % mod;
    X++;
  }
}
void DP() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j < n; j++) {
      if (n <= i + j) continue;
      long long I = i + 1;
      long long Z = I - 1;
      long long Y = j - 1;
      long long X = n - (Y + 2);
      dp[i][j] = C[X][Z - Y] * F[Z] % mod;
      dp[i][j] *= P[Z + 1];
      dp[i][j] %= mod;
    }
  }
}
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> x[i];
  init();
  DP();
  for (long long j = 1; j < n; j++) {
    for (long long i = 0; i < n; i++) {
      J[j] += dp[i][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      long long d = x[j] - x[i];
      long long k = j - i;
      ans += d * J[k] % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
