#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll x[n];
  for (ll i = 0; i < n; ++i) cin >> x[i];
  ll kaijo[n];
  kaijo[0] = 1;
  for (ll i = 0; i < n; ++i) {
    kaijo[i + 1] = kaijo[i] * (i + 1);
    kaijo[i + 1] %= 1000000007;
  }
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < n; ++j)
      if (j + i + 1 < n) {
        ll add = x[j + i + 1] - x[j];
        ans += (add * kaijo[n - 2 - j] * (j + 1)) % 1000000007;
      }
  }
  cout << ans << endl;
}
