#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E16;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long &pos, long long val) { pos = max(pos, val); }
void Min(long long &pos, long long val) { pos = min(pos, val); }
void Add(long long &pos, long long val) { pos = mod(pos + val); }
long double EPS = 1E-9;
int main() {
  long long n;
  cin >> n;
  long long kai[n];
  kai[n - 1] = 1;
  for (long long i = n - 2; i >= 0; i--) {
    kai[i] = (kai[i + 1] * (i + 1)) % (long long)(1E9 + 7);
  }
  long long x[n];
  long long y[n];
  for (long long i = 0; i <= n - 1; i++) {
    cin >> x[i];
    if (i >= 1) {
      y[i] = x[i] - x[i - 1];
    }
  }
  long long dp[n + 1][n + 1];
  dp[1][1] = 1;
  dp[2][1] = 1;
  dp[2][2] = 1;
  for (long long i = 3; i <= n - 1; i++) {
    for (long long j = 1; j <= i; j++) {
      if (j == 1) {
        dp[i][j] = (dp[i - 1][j] * (i - 1)) % (long long)(1E9 + 7);
      } else if (j == i) {
        dp[i][j] = 1;
      } else {
        dp[i][j] =
            (dp[i - 1][j] * (i - 1) + dp[i - 1][j - 1]) % (long long)(1E9 + 7);
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n - 1; i++) {
    for (long long j = 1; j <= i; j++) {
      ans = (ans + (((((kai[i] * j) * y[i]) % (long long)(1E9 + 7)) %
                     (long long)(1E9 + 7)) *
                    dp[i][j]) %
                       (long long)(1E9 + 7)) %
            (long long)(1E9 + 7);
    }
  }
  cout << ans << endl;
  return 0;
}
