#include <bits/stdc++.h>
using namespace std;
long long dp[2005][2005];
int main() {
  int n;
  cin >> n;
  long long x[n];
  for (int i = 0; i < (int)(n); i++) {
    cin >> x[i];
  }
  dp[3][1] = 2;
  dp[3][2] = 3;
  for (int i = 4; i <= n; i++) {
    for (int j = 1; j <= i - 1; j++) {
      int u = dp[i - 1][1];
      if (j == 1) {
        dp[i][j] = (long long)u * (i - 1);
        dp[i][j] %= (int)(1e9 + 7);
      } else {
        dp[i][j] = (long long)u + dp[i - 1][j - 1];
        dp[i][j] += dp[i - 1][j - 1] * (j - 1);
        dp[i][j] %= (int)(1e9 + 7);
        dp[i][j] += dp[i - 1][j] * (i - j - 1);
        dp[i][j] %= (int)(1e9 + 7);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < (int)(n - 1); i++) {
    ans += ((x[i + 1] - x[i]) % (int)(1e9 + 7)) * dp[n][i + 1];
    ans %= (int)(1e9 + 7);
  }
  cout << ans << endl;
  return 0;
}
