#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, N = 1e9 + 7, f = 1, tmp = 0;
  long long ans = 0;
  cin >> n;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) cin >> x.at(i);
  for (int i = 0; i < n - 1; i++) {
    f *= (i + 1) % N;
  }
  for (int i = 0; i < n - 1; i++) {
    tmp += f / (i + 1);
    ans += (x.at(i + 1) - x.at(i)) * tmp;
  }
  cout << long long(ans) % N << endl;
}
