#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;
template <int MAX_N = 100000, long long MOD = 1000000007LL>
class Combination {
  std::array<long long, MAX_N + 1> _fact;
  std::array<long long, MAX_N + 1> _fact_inv;

 public:
  long long inv(long long a) const {
    long long b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
  }
  long long fact(long long n) const { return _fact[n]; }
  long long fact_inv(long long n) const { return _fact_inv[n]; }
  long long perm(long long n, long long k) const {
    return fact(n) * fact_inv(n - k) % MOD;
  }
  long long comb(long long n, long long k) const {
    return perm(n, k) * fact_inv(k) % MOD;
  }
  Combination() : _fact{}, _fact_inv{} {
    _fact[0] = _fact[1] = 1LL;
    for (int i = 2; i <= MAX_N; ++i) {
      _fact[i] = _fact[i - 1] * i % MOD;
    }
    _fact_inv[MAX_N] = inv(_fact[MAX_N]);
    for (int i = MAX_N - 1; i >= 0; --i) {
      _fact_inv[i] = _fact_inv[i + 1] * (i + 1) % MOD;
    }
  }
};
Combination<> cm;
int main() {
  int n;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  ll ans = 0;
  constexpr ll mod = inf;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (j != n - 1) {
        ll t = cm.fact(j - i - 1);
        t *= cm.fact(n - j + i - 2);
        t %= mod;
        t *= cm.comb(n - 1, j - i + 1);
        t %= mod;
        t *= x[j] - x[i];
        t %= mod;
        ans += t;
        ans %= mod;
      } else {
        ll t = cm.fact(j - i - 1);
        t *= cm.fact(n - j + i - 1);
        t %= mod;
        t *= cm.comb(n - 1, j - i);
        t %= mod;
        t *= x[j] - x[i];
        t %= mod;
        ans += t;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
