#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long MOD = 1e9 + 7;
  long long n;
  cin >> n;
  long long fac = 1;
  for (long long i = 2; i < (long long)n - 1; i++) fac = fac * i % MOD;
  vector<long long> v(n);
  for (long long i = 0; i < (long long)n; i++) cin >> v[i];
  long long tmp = 0;
  for (long long i = 1; i < (long long)n; i++) tmp += v[i] - v[0];
  long long ans = tmp * fac;
  ans %= MOD;
  for (long long i = 1; i < (long long)n - 1; i++) {
    long long dif = v[i] - v[i - 1];
    tmp = tmp + dif * (i - 1) - dif * (n - 1 - i);
    ans += tmp * fac;
    ans %= MOD;
  }
  cout << ans << endl;
}
