#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long gcd(long long a, long long b) {
  if (a < b) {
    long long c = a;
    a = b;
    b = c;
  }
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long dp[2010][2010] = {0};
signed main() {
  long long n;
  cin >> n;
  if (n > 2000) return 0;
  vector<long long> x(n);
  vector<long long> y(n);
  for (long long i = 0; i < (n); i++) cin >> x[i];
  if (n == 2) {
    cout << x[1] - x[0] << endl;
    return 0;
  }
  for (long long i = 0; i < (n); i++) y[i] = x[i + 1] - x[i];
  dp[2][1] = 2;
  dp[2][2] = 3;
  dp[3][1] = 6;
  dp[3][2] = 9;
  dp[3][3] = 11;
  for (long long k = 3; k <= 2000; k++) {
    for (long long d = 1; d <= k; d++) {
      dp[k][d] = (k - 1 + MOD) % MOD + (dp[k - 1][d - 1] * d) % MOD +
                 (dp[k - 1][d] * (k - d)) % MOD;
      dp[k][d] %= MOD;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (n - 1); i++) {
    ans += y[i] * dp[n - 1][i + 1];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
