#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  int n;
  cin >> n;
  long long x[n];
  for (int i = 0; i < n; ++i) cin >> x[i];
  long long f = 1e9 + 7;
  long long dp[100000][100000];
  dp[0][1] = 1;
  dp[1][1] = 1;
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = 0;
    dp[i][1] = (dp[i - 1][1] * i) % f;
    for (int j = 2; j <= i; ++j) {
      dp[i][j] =
          ((i - j) * dp[i - 1][j] + j * dp[i - 1][j - 1] + dp[i - 1][1]) % f;
    }
  }
  long long d[n + 1];
  d[0] = 0;
  for (int i = 1; i <= n - 1; ++i) d[i] = (x[i] - x[i - 1]) % f;
  long long sum = 0;
  for (int i = 1; i <= n - 1; ++i) sum += (dp[n - 1][i] * d[i]) % f;
  cout << sum % f;
}
