#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  unsigned long long int X[N];
  unsigned long long int md = 0;
  for (int i = 0; i < (N); i++) {
    unsigned long long int x;
    cin >> x;
    X[i] = x;
    md = max((md * i) % (1000000007), (unsigned long long int)1);
    cout << "deb md: " << md << endl;
  }
  unsigned long long ans = 0;
  for (int i = 0; i < (N - 1); i++) {
    unsigned long long int diff = X[N - 1] - X[i];
    unsigned long long int tmp = ((2 * diff * md / (i + 1)) / 2) % (1000000007);
    ans = (ans + tmp) % (1000000007);
  }
  cout << ans;
  return 0;
}
