#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long Power(long long a, long long b) {
  if (b == 0) return 1;
  long long x = Power(a, b / 2);
  x = (x * x) % mod;
  if (b % 2) x = (x * a) % mod;
  return x;
}
long long x[1000000];
long long F[1000000];
long long iF[1000000];
long long pre[1000000];
long long inv(long long v) { return Power(v, mod - 2); }
long long C(long long n, long long k) {
  return (F[n] * ((iF[n - k] * iF[k]) % mod)) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  F[0] = 1;
  iF[0] = 1;
  for (int i = 1; i <= 5000; i++) {
    F[i] = (F[i - 1] * i) % mod;
    iF[i] = inv(F[i]);
  }
  int n;
  cin >> n;
  long long ret = 0;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int l = 1; l <= n; l++) {
    for (int r = n; r <= n; r++) {
      long long tot = (F[r - l - 1] * C(n - 1, r - l + (r != n))) % mod;
      tot = (tot * F[n - 1 - (r - l + (r != n))]) % mod;
      tot = (tot * (x[r] - x[l])) % mod;
      ret = (ret + tot) % mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = (inv(i) * inv(i + 1)) % mod;
    pre[i] = (F[n - 1] * pre[i]) % mod;
  }
  for (int l = 1; l <= n; l++) {
    for (int r = l + 1; r < n; r++) {
      long long tot = (pre[r - l] * (x[r] - x[l])) % mod;
      ret = (ret + tot);
    }
  }
  ret %= mod;
  cout << ret << endl;
}
