#include <bits/stdc++.h>
using namespace std;
long long test[213456], kai[123456];
signed main() {
  long long n, a, b = 1, ans = 0;
  cin >> n;
  for (long long h = 1; h < n; h++) {
    b *= h;
    b %= 1000000007;
    kai[h] = b;
  }
  for (long long h = 0; h < n; h++) {
    cin >> a;
    test[h] = a;
  }
  for (long long h = 0; h < n - 1; h++) {
    for (long long i = h + 1; i < n; i++) {
      cout << (kai[n - i - 1] + kai[i - h - 1] + kai[h]) * (test[i] - test[h])
           << endl;
      if (h == n - 2 && i == n - 1) {
        ans += kai[n - 1];
      } else {
        ans += (kai[n - i - 1] + kai[i - h - 1] + kai[h]) * (test[i] - test[h]);
      }
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
}
