#include <bits/stdc++.h>
using namespace std;
long long modpow(long long X, long long Y) {
  long long sum = X, cnt = 1;
  vector<long long> A;
  while (cnt <= Y) {
    cnt *= 2;
    A.push_back(sum);
    sum *= sum;
    sum %= 1000000007;
  }
  long long ret = 1, M = A.size();
  for (long long i = (long long)(1); i <= (long long)(M); i++) {
    if (Y >= (1ll << M - i)) {
      Y -= (1ll << M - i);
      ret *= A[M - i];
      ret %= 1000000007;
    }
  }
  return ret;
}
const long long MAX = 500000;
long long finv[MAX], fac[MAX];
void COMinit() {
  finv[0] = finv[1] = fac[0] = fac[1] = 1;
  for (long long i = (long long)(2); i < (long long)(MAX); i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    finv[i] = finv[i - 1] * modpow(i, 1000000007 - 2) % 1000000007;
  }
}
long long COM(long long n, long long k) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % 1000000007 * finv[n - k] % 1000000007;
}
signed main() {
  COMinit();
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = (long long)(0); i < (long long)(N); i++) cin >> A[i];
  long long ans = 0;
  for (long long i = (long long)(1); i < (long long)(N); i++) {
    long long X = A[i] - A[i - 1];
    for (long long j = (long long)(0); j < (long long)(i); j++) {
      ans += X * fac[N - 1] % 1000000007 * finv[i - j] % 1000000007 *
             fac[i - j - 1] % 1000000007;
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
}
