#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const long long MOD = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  vector<long long> fac(n);
  fac[0] = 1;
  for (int i = 1; i < n; i++) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= MOD;
  }
  long long ans = 0;
  for (int i = 0; i < n - 2; i++)
    for (int j = 0; j < n - 1; j++) {
      if (i >= j) continue;
      long long diff = x[j] - x[i];
      long long tmp = fac[j - i - 1] * fac[n - 1 - (j - i)];
      tmp %= MOD;
      ans += (diff * tmp) % MOD;
      ans %= MOD;
    }
  cout << ans << endl;
  for (int i = 0; i < n - 1; i++) {
    long long diff = x[n - 1] - x[i];
    long long tmp = fac[n - 2 - i] * fac[i + 1];
    tmp %= MOD;
    ans += (diff * tmp) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
