#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long mod = 1e9 + 7;
void chmod(long long &M) {
  if (M >= mod)
    M %= mod;
  else if (M < 0) {
    M += (abs(M) / mod + 1) * mod;
    M %= mod;
  }
}
long long modpow(long long x, long long n) {
  if (n == 0) return 1;
  long long res = modpow(x, n / 2);
  if (n % 2 == 0)
    return res * res % mod;
  else
    return res * res % mod * x % mod;
}
int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
double argument(const pair<double, double> &a, const pair<double, double> &b) {
  double ax = a.first, ay = a.second, bx = b.first, by = b.second;
  return atan2(by - ay, bx - ax);
}
const int MAX = 1000005;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  COMinit();
  long long N;
  cin >> N;
  vector<long long> x(N + 1, 0);
  vector<long long> f(N + 1, 0);
  f[0] = 1;
  for (int i = 1; i < N + 1; i++) f[i] = f[i - 1] * i % mod;
  for (int i = 0; i < N; i++) cin >> x[i + 1];
  vector<long long> cum(N + 1, 0);
  for (int i = 1; i < N + 1; i++) {
    cum[i] = cum[i - 1] + x[i];
    chmod(cum[i]);
  }
  vector<long long> seg(N + 1, 0);
  for (int i = 1; i < N; i++) {
    seg[1] += x[i];
    seg[1] %= mod;
  }
  for (int i = 2; i < N; i++) {
    seg[i] =
        seg[i - 1] - (cum[N - 1] - cum[N - 1 - i - 1]) + (cum[N - 1] - cum[i]);
    chmod(seg[i]);
  }
  long long ans = 0;
  for (int k = 1; k < N - 1; k++) {
    long long add = fac[N - 1] * modpow(fac[k + 1], mod - 2) % mod *
                    fac[N - k - 2] % mod * seg[k] % mod;
    ans += add;
    chmod(ans);
  }
  cout << ans << endl;
  for (int l = 1; l < N; l++) {
    long long add = COM(N - 1, N - l) * f[N - 1 - l] % mod * f[l - 1] % mod *
                    (x[N] - x[l]) % mod;
    ans += add;
    chmod(ans);
  }
  cout << ans << endl;
  return 0;
}
