#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;
long long func(const long long x, const long long m) {
  long long ret = 0;
  for (long long i = 1; i <= m; ++i) ret += (x / i) % mod;
  return ret % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, ans = 0, val = 1;
  cin >> n;
  vector<long long> v(n, 0), p(n - 1, 0), f(n - 1, 0), d(n - 1, 0);
  for (long long(i) = 0; i < (n); ++(i)) cin >> v[i];
  for (long long(i) = 0; i < (n - 1); ++(i)) d[i] = v[i + 1] - v[i];
  for (long long i = 0; i < n - 1; ++i) {
    val *= (i + 1);
    p[i] = func(val, i + 1);
  }
  f[0] = val;
  for (long long i = 1; i < n - 1; ++i) f[i] += f[i - 1] / (i + 1);
  for (long long i = 0; i < n - 1; ++i) ans += (d[i] * p[i] * f[i]) % mod;
  ans %= mod;
  cout << (ans) << endl;
  return 0;
}
