#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
const long long LINF = 1e18 + 5;
const long long M = 1000000007;
vector<long long> fac(1000000);
vector<long long> ifac(1000000);
long long mpow(long long x, long long n) {
  long long ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % M;
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}
long long comb(long long a, long long b) {
  if (a == 0 && b == 0) return 1;
  if (a < b || a < 0) return 0;
  long long tmp = ifac[a - b] * ifac[b] % M;
  return tmp * fac[a] % M;
}
void init_comb() {
  fac[0] = 1;
  ifac[0] = 1;
  for (long long i = 0; i < 1000000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M;
    ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;
  }
}
int main() {
  init_comb();
  long long N;
  long long X[100000];
  long long Y[100000] = {};
  long long A[100000] = {};
  long long A1[100000] = {};
  cin >> N;
  if (N > 2000) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 0; i < N; i++) cin >> X[i];
  for (long long i = 0; i < N; i++) {
    Y[i] = X[i + 1] - X[i];
  }
  for (long long i = 0; i < N - 1; i++) {
    for (long long j = 0; j < N; j++) {
      A1[j] = 0;
    }
    if (i == 0) {
      A1[0] = 1;
      A[0] = 1;
      continue;
    }
    for (long long j = 0; j < i + 1; j++) {
      if (j == 0) {
        A1[0] = (i * A[0]) % M;
        continue;
      }
      A1[j] = ((j + 1) * A[j - 1]) % M;
      A1[j] += ((i - j) * A[j]) % M;
    }
    for (long long j = 0; j < i + 1; j++) {
      A1[j] += fac[i] % M;
      A1[j] %= M;
      A[j] = A1[j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N - 1; i++) {
    ans += Y[i] * A[i];
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}
