#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  vector<long> d(N - 1);
  for (int i = 0; i < N - 1; i++) {
    d[i] = p[i + 1] - p[i];
  }
  long mod = 1000000007;
  long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    long a = d[i];
    long dist = 0;
    for (int k = 1; k <= i + 1; k++) {
      long pow = 1;
      for (int j = 1; j < N; j++) {
        if (k != j) pow = pow * j % mod;
      }
      dist = (dist + pow) % mod;
    }
    ans = (ans + dist) % mod;
  }
  cout << ans << endl;
}
