#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  if (N > 2000) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> x(N), f(N + 1, 1);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    f[i + 1] = (f[i] * (i + 1)) % MOD;
  }
  vector<vector<ll>> v(N, vector<ll>(N, 0)), s(N, vector<ll>(N + 1, 0));
  v[0][0] = 1;
  s[0][1] = 1;
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < i + 2; j++) {
      v[i + 1][j] = (v[i][j] * (i + 1 - j)) % MOD;
      v[i + 1][j] += s[i][j];
      v[i + 1][j] %= MOD;
      v[i + 1][j] += (f[i + 1] * (j + 1)) % MOD;
      v[i + 1][j] %= MOD;
      s[i + 1][j + 1] = (s[i + 1][j] + v[i + 1][j]) % MOD;
    }
  }
  ll ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += (x[i + 1] - x[i]) * v[N - 2][i];
    ans %= MOD;
  }
  cout << ans << endl;
}
