#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 2005;
long long A[N][N], S[N][N], a[N];
void table(int n) {
  memset(A, 0, sizeof(A));
  memset(S, 0, sizeof(S));
  for (int i = 1; i <= n; ++i) A[i][1] = i;
  for (int i = 2; i <= n; ++i)
    for (int j = 2; j <= i; ++j) A[i][j] = (A[i][j - 1] * (i - j + 1)) % M;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) S[j][i] = (S[j - 1][i] + A[j][i]) % M;
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  table(n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  long long ans = ((A[n - 1][n - 1] % M) * ((a[n] - a[1]) % M)) % M;
  for (int i = 2; i < n; ++i) {
    long long t = ((S[n - 2][i - 1] % M) * ((a[n] - a[i]) % M)) % M;
    ans = (ans + t) % M;
  }
  printf("%lld\n", (ans + M) % M);
  return 0;
}
