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