#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
const int SIZE = 100050;
long long mod_pow(long long x, long long n, long long mod) {
  if (n == 0) return 1;
  long long res = mod_pow((x * x) % mod, n / 2, mod);
  if (n & 1) res = (res * x) % mod;
  return res;
}
signed main() {
  long long ex[SIZE] = {1, 0};
  for (int i = 1; i < SIZE; i++) {
    ex[i] = ex[i - 1] * i % 1000000007;
  }
  long long inv[SIZE] = {1, 0};
  long long sol[SIZE] = {1, 0};
  for (int i = 1; i < SIZE; i++) {
    inv[i] = mod_pow(i, 1000000007 - 2, 1000000007);
    sol[i] = inv[i];
  }
  for (int i = 1; i < SIZE; i++) {
    inv[i] = inv[i - 1] * inv[i] % 1000000007;
  }
  long long N;
  cin >> N;
  vector<long long> A;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
  }
  long long DP[SIZE] = {};
  long long num = 1;
  for (int i = N - 1; i >= 1; i--) {
    num++;
    DP[i] = (num - 1) * DP[i + 1] % 1000000007;
    for (int j = 1; j <= N; j++) {
      if (i + j > N) continue;
      long long idx = i + j;
      long long com;
      if (i + j < N)
        com = ex[num - 1] * sol[j] % 1000000007 * sol[j + 1] % 1000000007;
      if (i + j == N) com = ex[num - 2];
      DP[i] += com * (A[idx - 1] - A[i - 1]) % 1000000007;
      DP[i] %= 1000000007;
    }
  }
  cout << DP[1] << endl;
  return 0;
}
