#include <bits/stdc++.h>
using namespace std;
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
int main() {
  int N;
  cin >> N;
  vector<unsigned long long> x(N), y(N - 1);
  for (int i = 0; i < N; i++) cin >> x.at(i);
  for (int i = 0; i < N - 1; i++) y.at(i) = x.at(i + 1) - x.at(i);
  unsigned long long a = 1, b = 1;
  for (int i = 1; i < N; i++) {
    a = (a % 1000000007) * (i % 1000000007) % 1000000007;
  }
  unsigned long long sum = 0;
  for (int i = 0; i < N - 1; i++) {
    unsigned long long tmp =
        (y.at(i) % 1000000007) * (a % 1000000007) % 1000000007;
    sum = (sum + tmp) % 1000000007;
    int j = 0;
    unsigned long long c = modinv(2, 1000000007);
    c *= a;
    while (j < i) {
      tmp = ((y.at(i) % 1000000007) * (b % 1000000007)) % 1000000007;
      sum = (sum + tmp) % 1000000007;
      j++;
      c = modinv((2 + j), 1000000007);
      c *= a;
    }
  }
  sum %= 1000000007;
  cout << sum;
  return 0;
}
