#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  long long a[n - 1], ans = 0, buf, buf2, m = 1;
  for (int i = 0; i < n; i++) {
    cin >> buf;
    if (i != 0) {
      a[i - 1] = buf - buf2;
    }
    buf2 = buf;
    m *= (i + 1);
  }
  m /= n;
  for (int i = 0; i < n - 1; i++) {
    ans += m * (i + 2) / 2 * a[i];
  }
  ans = ans % 1000000007;
  cout << ans << endl;
}
