#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 69;
const int mod = 1e9 + 7;
long long n, m, mx, ind, ans, len, x, y, a, b, t, k, T;
long long fix[N], A[N], dp[N], B[N];
vector<long long> v[N];
vector<pair<long long, long long> > P;
string s[N], S;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  x = 1;
  for (int i = 1; i <= n - 3; i++) x *= i, x %= mod;
  if (n == 3)
    y = x - 1;
  else
    y = x;
  for (int i = n; i >= 2; i--) {
    ans += (y + 1) * (A[n] - A[i]) % mod;
    ans %= mod;
  }
  x *= (n - 2);
  x++;
  x %= mod;
  ans += (x * (A[n] - A[1])) % mod;
  ans %= mod;
  cout << ans << endl;
}
