#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, x[100010], y[100010], mod = 1000000000 + 7, k[100010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    k[i] = 1;
  }
  for (int i = 1; i < n; i++) {
    y[i] = x[i] - x[i - 1];
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= n - 1; j++) {
      if (i == j) continue;
      k[i] = (k[i] * j) % mod;
    }
  }
  long long ans = 0, b = 0;
  for (int i = 1; i < n; i++) {
    b = (b + k[i]) % mod;
    ans = (ans + (b * y[i]) % mod) % mod;
  }
  cout << ans;
}
