#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
const long long N_MAX = 100005;
long long inv[N_MAX], fac[N_MAX], finv[N_MAX];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < N_MAX; i++) {
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    fac[i] = fac[i - 1] * (long long)i % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
long long combination(long long C, long long D) {
  if (C < D || C < 1) return 0;
  return fac[C] * (finv[D] * finv[C - D] % mod) % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  long long N;
  cin >> N;
  vector<long long> x(N);
  for (int i = 0; i < (int)N; ++i) cin >> x[i];
  long long res1 = 0;
  for (int i = 0; i < (int)N - 1; ++i) {
    for (int j = 0; j < (int)N - 1; ++j) {
      if (i < j) {
        long long tmp =
            combination(N - 1, j - i + 1) * fac[N - j + i - 2] % mod;
        tmp *= fac[j - i - 1];
        tmp %= mod;
        tmp *= (x[j] - x[i]);
        tmp %= mod;
        res1 += tmp;
        res1 %= mod;
      }
    }
  }
  long long res2 = 0;
  for (int i = 0; i < (int)N - 1; ++i) {
    long long tmp = combination(N - 1, N - i - 1) * fac[i] % mod;
    tmp *= fac[N - i - 2];
    tmp %= mod;
    tmp *= (x[N - 1] - x[i]);
    tmp %= mod;
    res2 += tmp;
    res2 %= mod;
  }
  cout << (res1 + res2) % mod << endl;
  return 0;
}
