#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int64_t modinv(int64_t a) {
  int64_t b = MOD, u = 1, v = 0;
  while (b) {
    int64_t t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
int main() {
  int64_t answer = 0, N, sum;
  cin >> N;
  vector<int64_t> s(N, 0), t(N + 1, 1), u(N + 1, 1);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
    if (i > 0) {
      t.at(i + 1) *= t.at(i) * (i + 1) % MOD;
      u.at(i + 1) = modinv(i + 1);
    }
  }
  for (int i = 1; i < N; i++) {
    sum = t.at(N - 1);
    for (int j = 2; j <= i; j++) {
      sum += t.at(N - 1) * u.at(j) % MOD;
      sum %= MOD;
    }
    answer += ((s.at(i) - s.at(i - 1)) * sum) % MOD;
    answer %= MOD;
  }
  cout << answer << endl;
}
