#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<vector<long long>> X(N);
  --N;
  for (int i = 0; i < N; ++i) {
    X[i].resize(i + 5);
  }
  X[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      X[i][j] = X[i - 1][j] * (i + 1);
      X[i][j] %= MOD;
    }
    X[i][i] = X[i][i - 1] + X[i - 1][0];
    X[i][i] %= MOD;
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += (A[i + 1] - A[i]) * X[N - 1][i];
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}
