#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
int main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; ++i) {
    cin >> x[i];
  }
  vector<long long> s(n);
  s[n - 1] = 0;
  for (long long i = n - 2; i >= 0; --i) {
    s[i] += s[i + 1] + (x[i + 1] - x[i]);
  }
  long long ans = 0;
  for (long long i = n - 2; i >= 0; --i) {
    ans += (ans * (i + 1)) % MOD + (s[i] * (i + 1)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
