#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  vector<long> x(n);
  for (long i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  long total = 0;
  for (long i = 0; i < n - 1; i++) {
    long pattern = 1;
    for (long j = n - 2; j >= i; j--) {
      pattern *= n - 1 - j;
    }
    total += (x.at(n - 1) - x.at(i)) * pattern;
  }
  if (total >= 1000000007) {
    cout << total % 1000000007 << endl;
  } else {
    cout << total << endl;
  }
}
