#include <bits/stdc++.h>
using namespace std;
int main() {
  long MOD = 1000000007;
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  long sum = 0;
  for (int i = 1; i <= n - 2; i++) {
    sum += i * (a[i + 1] - a[n - 1 - i]) % MOD;
    sum %= MOD;
  }
  sum = (sum * (n - 1)) % MOD * (n - 2) % MOD;
  long ss = 0;
  for (int i = 1; i < n; i++) {
    ss -= a[i];
    ss += a[n];
    ss %= MOD;
  }
  while (n > 2) {
    ss *= (n - 2);
    ss % MOD;
    n--;
  }
  cout << (sum + ss) % MOD << endl;
}
