#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long n;
vector<long long> x;
int main() {
  cin >> n;
  x.resize(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> x[i];
  }
  long long ans = 0;
  long long jud = 1;
  long long jud2 = 0;
  long long tmp = 0;
  for (long long i = n - 2; i >= (0); --i) {
    jud2++;
    jud *= jud2;
    tmp = (x[n - 1] - x[i]) * jud;
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << (ans) << endl;
}
