#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long fact(long long k) {
  long long sum = 1;
  for (long long i = 2; i <= k; i++) sum *= i;
  return sum;
}
long long fact_mod(long long k) {
  long long sum = 1;
  for (long long i = 2; i <= k; i++) sum = (sum * i) % MOD;
  return sum;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9')
    return c - '0';
  else
    return -1;
}
long long pow_mod(int a, int b) {
  long long ans = 1;
  for (int i = 0; i < b; i++) ans = (ans * a) % MOD;
  return ans;
}
long long powll(long long a, long long b) {
  long long ans = 1;
  for (long long i = 0; i < b; i++) ans = ans * a;
  return ans;
}
long long modinv(long long a) {
  long long b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
vector<long long> func(long long n, long long k) {
  vector<long long> vec;
  long long tmp, ptr = 0;
  vec.push_back(fact_mod(n - 1));
  for (long long i = 2; i <= n - k - 1; i++) {
    tmp = (vec[ptr] * modinv(i)) % MOD;
    vec.push_back(vec[ptr] - tmp);
    if (vec[ptr + 1] < 0) vec[ptr + 1] += MOD;
    vec[ptr] = tmp;
    ptr++;
  }
  return vec;
}
int main() {
  long long n, ans = 0;
  cin >> n;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  vector<long long> cntVec;
  cntVec = func(n, 0);
  long long cnt;
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 1; i + j < n; j++) {
      if (i == 0)
        cnt = cntVec[j - 1];
      else if (i + j == n - 1) {
        cnt = cntVec[n - 2];
        for (int k = 0; k < i; k++) cnt += cntVec[n - 3 - k];
      } else {
        cnt = cntVec[j - 1];
      }
      ans = (ans + (((x[i + j] - x[i]) * cnt) % MOD)) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
