#include <bits/stdc++.h>
using namespace std;
int DP(int i, int j);
int dp[2001][2001];
int x[100000];
int mod = 1000000007;
int fact[100000];
int Fact();
int n;
int main() {
  int i, j;
  cin >> n;
  i = Fact();
  for (i = 1; i <= n; i++) {
    cin >> x[i];
  }
  for (i = 0; i < 2000; i++) {
    for (j = 0; j < 2000; j++) {
      dp[i][j] = -1;
    }
  }
  return DP(1, n);
}
int DP(int i, int j) {
  int ii;
  if (dp[i][j] == -1) {
    dp[i][j] = 0;
    if (i == j - 1) {
      dp[i][j] = x[j] - x[i];
      return x[j] - x[i];
    } else {
      dp[i][j] =
          ((DP(i + 1, j) + fact[j - i - 1] * (x[j] - x[i])) * DP(j, n)) % mod;
      return dp[i][j];
    }
  } else {
    return dp[i][j];
  }
}
int Fact() {
  int i;
  fact[0] = 1;
  for (i = 1; i < 100000; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  return 0;
}
