#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  long long ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    long long factor = 1;
    for (int j = 1; j <= N - 1; ++j) {
      if (j != i + 1) factor *= j;
      factor %= (1000000007LL);
    }
    ans += factor * (x[N - 1] - x[i]) % (1000000007LL);
    ans %= (1000000007LL);
  }
  cout << ans << endl;
  return 0;
}
