#include <bits/stdc++.h>
using namespace std;
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;
  for (int i = 0; i < N - 1; i++) {
    a *= (i + 1);
    a %= 1000000007;
  }
  unsigned long long sum = 0;
  for (int i = 0; i < N - 1; i++) {
    unsigned long long tmp = (y.at(i) % 1000000007) * (a % 1000000007);
    tmp %= 1000000007;
    sum += tmp;
    sum %= 1000000007;
    int j = 0;
    unsigned long long b = a / 2;
    while (j < i) {
      tmp = (y.at(i) % 1000000007) * (b % 1000000007);
      tmp %= 1000000007;
      sum += tmp;
      sum %= 1000000007;
      j++;
      b = a / (2 + j);
    }
  }
  sum %= 1000000007;
  cout << sum;
  return 0;
}
