#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int n;
int pos[2020];
long long dp[2020][2020];
long long f[2020];
int main() {
  scanf("%d", &n);
  f[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) f[i] = (f[i + 1] * (i + 1)) % mod;
  for (int i = 0; i < n; i++) scanf("%d", &pos[i]);
  memset(dp, 0, sizeof(dp));
  dp[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[j][i] += ((1LL * (i - 1) * dp[j][i - 1]) % mod);
      dp[j][i] += dp[j - 1][i - 1];
      dp[j][i] %= mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < i + 1; j++)
      sum = (sum + (1LL * dp[j][i] * j) % mod) % mod;
    sum *= f[i];
    sum %= mod;
    ans += ((sum * (pos[i] - pos[i - 1])) % mod);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
