#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[n];
  dp[0] = 2;
  dp[1] = 3;
  for (int i = 2; i < n - 1; ++i) {
    for (int j = i - 1; j >= 1; --j) {
      dp[j] = ((j + 1) * dp[j - 1] + (i - j) * dp[j] + dp[0]) % f;
    }
    dp[i] = (dp[i - 1] + dp[0]) % f;
    dp[0] = (dp[0] * (i + 1)) % f;
  }
  long long d[n + 1];
  d[0] = 0;
  for (int i = 0; i < n - 1; ++i) d[i] = (x[i + 1] - x[i]) % f;
  long long sum = 0;
  for (int i = 0; i < n - 1; ++i) sum += (dp[i] * d[i]) % f;
  cout << sum % f;
}
