#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll pv(ll N, ll div) {
  ll n = N;
  ll ans = 1;
  while (n > 0) {
    if (n != div) {
      ans *= n;
      ans %= MOD;
    }
    n--;
  }
  return ans;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> xs(N + 1);
  for (int i = 1; i <= N; ++i) {
    cin >> xs[i];
  }
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    ll total = 0;
    for (int j = i + 1; j <= N; ++j) {
      total += (xs[j] - xs[i]) % MOD;
      total %= MOD;
    }
    auto factor = pv(N - 1, N - i);
    total *= (pv(N - 1, N - i) % MOD);
    ans += (total % MOD);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
