#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7 + (1e+9);
int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> x(n, 0);
  vector<ll> v(n - 1, 0);
  for (ll i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (ll i = 1; i < n; i++) {
    v[i - 1] = x[i] - x[i - 1];
  }
  vector<vector<ll> > dp(n, vector<ll>(n + 2, 0));
  dp[2][0] = 0;
  dp[2][1] = 2;
  dp[2][2] = 3;
  dp[2][3] = 0;
  for (ll i = 3; i < n; i++) {
    for (ll j = 0; j < i; j++) {
      dp[i][j + 1] = (j * dp[i - 1][j] % MOD + dp[i - 1][j] + dp[i - 1][1] +
                      (i - j - 1) * dp[i - 1][j + 1] % MOD) %
                     MOD;
    }
  }
  for (ll i = 1; i < n; i++) {
    ans = (ans + dp[n - 1][i] * v[i - 1]) % MOD;
  }
  cout << ans << endl;
}
