#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int64_t infi = 1147483600;
const long long infl = 4e18 + 5;
const char EOL = '\n';
int main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; ++i) {
    cin >> x[i];
  }
  vector<long long> p(n + 1, 1), q(n + 1, 1), r(n + 1, 1);
  long long tmp = 1;
  for (long long i = n - 1; i >= 1; --i) {
    p[i] = p[i + 1] * i;
    p[i] %= 1000000007;
  }
  for (long long i = 1; i < n; ++i) {
    q[i] = q[i - 1] * i;
    q[i] %= 1000000007;
  }
  for (long long i = 1; i < n; ++i) {
    r[i] = q[i - 1] * p[i + 1];
    r[i] %= 1000000007;
  }
  long long sum = 0;
  for (long long i = n - 2; i >= 0; --i) {
    for (long long j = i + 1; j <= n - 1; ++j) {
      long long cur = x[j] - x[i];
      sum += cur * r[n - 1 - i];
      sum %= 1000000007;
    }
  }
  cout << sum << endl;
}
