#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll modpow(ll x, ll n, ll mod = MOD) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
ll f[100005], fi[100005];
ll perm(int n, int r) {
  if (n < r) return 0;
  return f[n] * fi[n - r] % MOD;
}
ll comb(int n, int r) {
  if (n < r) return 0;
  return f[n] * fi[r] % MOD * fi[n - r] % MOD;
}
ll dp[2005][2005];
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i] = f[i - 1] * i % MOD;
  }
  fi[n] = modpow(f[n], MOD - 2);
  for (int i = n; i > 0; --i) {
    fi[i - 1] = fi[i] * i % MOD;
  }
  ll ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int m = n - 1 - i;
    ll hoge = 0;
    for (int j = 0; j < m; ++j) {
      ll tmp = 0;
      for (int k = 0; k < m; ++k) {
        if (m - k - 1 < j) continue;
        ll foo = perm(m - k - 1, j);
        if (j < m - 1) {
          (foo *= k * f[m - j - 2] % MOD) %= MOD;
        }
        (tmp += foo) %= MOD;
      }
      (hoge += tmp) %= MOD;
      (tmp *= perm(n - 1, n - m - 1)) %= MOD;
      (ans += (x[i + j + 1] - x[i]) % MOD * tmp % MOD) %= MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}
