#include <bits/stdc++.h>
using namespace std;
class Combination {
 public:
  Combination(int64_t max_num, int64_t mod) {
    fact_.resize(max_num + 1, 1);
    inv_fact_.resize(max_num + 1, 1);
    mod_ = mod;
    for (int64_t i = 2; i <= max_num; i++) {
      fact_[i] = i * fact_[i - 1] % mod_;
      inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
      assert(fact_[i] * inv_fact_[i] % mod_ == 1);
    }
  }
  int64_t operator()(int64_t n, int64_t m) const {
    if (m < 0 || m > n) return 0;
    return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
  }
  int64_t fact(int64_t i) { return fact_[i]; }

 private:
  int64_t MODpow(int64_t n, int64_t m) const {
    int64_t result = 1;
    while (m) {
      if (m % 2 == 1) {
        result *= n;
        result %= mod_;
      }
      m /= 2;
      n *= n;
      n %= mod_;
    }
    return result;
  }
  vector<int64_t> fact_, inv_fact_;
  int64_t mod_;
};
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> x(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> x[i];
  }
  vector<int64_t> sum(N + 1, 0);
  for (int64_t i = 0; i < N; i++) {
    sum[i + 1] = sum[i] + x[i];
  }
  constexpr int64_t MOD = 1e9 + 7;
  Combination comb(N, MOD);
  int64_t ans = 0;
  for (int64_t i = 1; i < N; i++) {
    int64_t f = comb(N - 1, i + 1) * comb.fact(i - 1) % MOD *
                comb.fact(N - i - 2) % MOD;
    int64_t num = (sum[N - 1] - sum[N - 1 - i]) - sum[i];
    (ans += f * num) %= MOD;
    (ans += (x[N - 1] - x[N - 1 - i]) * comb(N - 1, i) % MOD *
            comb.fact(N - 1 - i) % MOD * comb.fact(i - 1)) %= MOD;
  }
  cout << ans << endl;
}
