#include <bits/stdc++.h>
using namespace std;
const long long INF = 200000000000000;
double pi = 3.141592653589793;
int main(void) {
  int N;
  int xx[100005];
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> xx[i];
  }
  int aa[2005][2005] = {1};
  long long fac = 1;
  aa[1][0] = 1;
  aa[1][2] = 1;
  aa[1][3] = 1;
  aa[1][1] = 1;
  for (size_t L = 2; L < N; L++) {
    fac *= L - 1;
    fac %= (1000000007);
    ;
    for (size_t i = 0; i < L; i++) {
      long long tmp = fac;
      if (i < L - 1) {
        tmp += (L - i - 1) * aa[L - 1][i] % (1000000007);
        ;
      }
      if (1 <= i) {
        tmp += (i + 1) * aa[L - 1][i - 1] % (1000000007);
        ;
      }
      aa[L][i] = tmp % (1000000007);
      ;
    }
  }
  long long dx[2005];
  for (size_t i = 1; i < N; i++) {
    dx[i - 1] = (xx[i] - xx[i - 1]) % (1000000007);
    ;
  }
  long long ans = 0;
  for (size_t i = 0; i < N - 1; i++) {
    ans += dx[i] * aa[N - 1][i];
    ans %= (1000000007);
    ;
  }
  cout << ans << endl;
}
