#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const int inf = 2e9;
const ll MOD = 1000000007;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, -1, 0, 1};
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res % mod * a % mod;
    a = a % mod * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }
int main() {
  ll N;
  cin >> N;
  ll info[N];
  for (ll i = 0; i < N; i++) cin >> info[i];
  ll ans = 0;
  ll p = 1;
  for (int i = 1; i < N; i++) {
    p = p * i;
    p %= MOD;
  }
  ll inv[N];
  for (ll i = 0; i < N; i++) inv[i] = modinv(i, MOD);
  for (ll i = 1; i < N; i++) {
    for (ll j = 0; j < N - i; j++) {
      if (j + i != N - 1)
        ans = ans + p * inv[i] % MOD * inv[i + 1] % MOD *
                        (info[i + j] - info[j]) % MOD;
      else
        ans = ans + p * inv[i] % MOD * (info[i + j] - info[j]) % MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
