#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = (unsigned long long)1e9 + 7;
long long mpow(long long x, long long n) {
  long long ans = 1;
  x %= mod;
  while (n != 0) {
    if (n & 1) ans = ans * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return ans;
}
long long inv_mod(long long a) { return mpow(a, mod - 2); }
int main(void) {
  long long n;
  cin >> n;
  vector<long long> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  vector<long long> dist(n);
  for (int i = 0; i < n - 1; i++) dist[i + 1] = xs[i + 1] - xs[i];
  vector<long long> modInvs(n, 0);
  for (long long i = 1; i < n; i++) {
    modInvs[i] = (modInvs[i - 1] + inv_mod(i)) % mod;
  }
  long long sum = 0;
  for (long long i = 1; i < n; i++) {
    long long elem = dist[i] * modInvs[i];
    (sum += elem) %= mod;
  }
  cout << sum << endl;
  return 0;
}
