#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
using Graph = vector<vector<long long>>;
int main() {
  long long N;
  cin >> N;
  vector<long long> X(N), sum(N + 1);
  for (long long i = (long long)0; i < (long long)N; i++) {
    cin >> X[i];
  }
  long long ans = 0;
  long long a = 1, b = 1;
  for (long long i = (long long)0; i < (long long)N - 1; i++) {
    a *= (i + 1);
    b *= (i + 1);
    a %= MOD;
    b %= MOD;
  }
  a *= 2;
  a--;
  long long d = (a - b) / (N - 2);
  for (long long i = (long long)N - 1; i >= (long long)0; i--) {
    if (i == 0) break;
    long long D = X[i] - X[i - 1];
    ans += (a - d * (N - i)) * D;
  }
  cout << ans << endl;
}
