#include <bits/stdc++.h>
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
using namespace std;
long long f(long long x, long long mod) {
  if (x == 0) return 1;
  long long res = 1LL;
  for (long long i = x; i > 0; i--) {
    res *= i % mod;
  }
  return res;
}
void solve() {
  long long mod = 1000000007;
  long long N;
  cin >> N;
  vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  long long total = 0;
  for (long long i = 1; i < N; i++) {
    for (long long j = 0; j < N - 1; j++) {
      total += x[min(N - 1, j + i)] - x[j];
      total %= mod;
    }
  }
  cout << total * f(N - 2, mod) % mod << endl;
}
signed main() { solve(); }
