#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, tmp, di = 1000000007, ans;
  vector<long long int> v, p;
  cin >> n;
  v.resize(n + 1);
  p.resize(2020);
  for (int i = 1; i <= n; i++) cin >> v[i];
  p[0] = 1;
  p[1] = 1;
  for (int i = 2; i < 2020; i++) {
    p[i] = p[i - 1] * i;
    p[i] = p[i] % di;
  }
  if (n <= 2000) {
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j < n + 1; j++) {
        tmp = 0;
        if (i == 1 && j == 2) {
          tmp = p[n - 1];
        } else {
          tmp += p[j - i - 1];
          tmp += p[n] / p[j + 1];
          tmp = tmp % di;
        }
        tmp *= v[j] - v[i];
        tmp = tmp % di;
        ans += tmp;
        ans = ans % di;
      }
    }
  }
  cout << ans << endl;
}
