#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long mp(long long b, long long e) {
  if (e == 0) return 1;
  long long ans = mp(b, e / 2);
  ans = ans * ans % mod;
  if (e % 2) ans = ans * b % mod;
  return ans;
}
int main() {
  int N;
  scanf("%d", &N);
  long long x[N], ans = 0, fac = 1, mi[N];
  for (int i = 0; i < N; ++i) scanf("%lld", &x[i]);
  for (int i = 1; i < N; ++i) fac = (fac * i) % mod;
  for (int i = 1; i < N; ++i) mi[i] = mp(i, mod - 2);
  for (int i = 0; i < N - 1; ++i) {
    for (int j = 1; i + j < N - 1; ++j)
      ans = (ans +
             fac * mi[j] % mod * mi[j + 1] % mod * (x[i + j] - x[i]) % mod) %
            mod;
    ans = (ans + fac * mi[N - i - 1] % mod * (x[N - 1] - x[i]) % mod) % mod;
  }
  printf("%lld", ans);
  return 0;
}
