#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
int main() {
  uint N;
  cin >> N;
  vector<uint> x(N);
  for (uint i = 0; i < N; i++) cin >> x[i];
  ull E = 0;
  ull mod = pow(10, 9) + 7;
  for (uint i = 1; i < N; i++) {
    E = (E * i) % mod;
    ull Ei = (x[i] - x[i - 1]) * (N - i);
    E = (E + Ei) % mod;
  }
  cout << E;
  return 0;
}
