#include <bits/stdc++.h>
using namespace std;
long long int fac[2000000 + 1];
long long int inv[2000000 + 1];
long long int finv[2000000 + 1];
long long int comb(long long int n, long long int k) {
  return (((fac[n] * finv[n - k]) % 1000000007) * finv[k]) % 1000000007;
}
void init() {
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for (int i = 2; i <= 2000000; i++) {
    fac[i] = (fac[i - 1] * i) % 1000000007;
    inv[i] =
        ((-(1000000007 / i) * inv[1000000007 % i]) % 1000000007 + 1000000007) %
        1000000007;
    finv[i] = (finv[i - 1] * inv[i]) % 1000000007;
  }
}
long long int pp(long long int a, long long int b) {
  return (a * b) % 1000000007;
}
int main(int argc, char const *argv[]) {
  long long int n;
  std::cin >> n;
  vector<long long int> x(n);
  init();
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) std::cin >> x[i];
  for (long long int i = 0; i < n - 1; i++) {
    for (long long int j = i + 1; j < n; j++) {
      long long int b = j == n - 1 ? j - i : j - i + 1;
      long long int p;
      if (j == n - 1)
        p = pp(fac[n - 1], inv[b]);
      else
        p = p = pp(fac[n - 1], pp(inv[b], inv[b - 1]));
      p = pp(p, x[j] - x[i]);
      ans = (ans + p) % 1000000007;
    }
  }
  std::cout << ans << '\n';
  return 0;
}
