#include <bits/stdc++.h>
using namespace std;
int factorial[200001];
void set_factorial(int n) {
  long long f = 1;
  factorial[0] = 1;
  for (int i = (1); i <= (n); i++) {
    f = (long long)i * (long long)factorial[i - 1];
    factorial[i] = (int)(f % (1000000007));
  }
}
int powbin(int base, int p) {
  long long mul;
  if (p == 1)
    mul = base;
  else {
    mul = (long long)powbin(base, p / 2);
    mul = (mul * mul) % (1000000007);
    if (p % 2) mul *= base;
  }
  return (int)(mul % (1000000007));
}
int combination(int n, int r) {
  long long mul;
  mul = factorial[n];
  mul = (mul * powbin(factorial[r], (1000000007) - 2)) % (1000000007);
  mul = (mul * powbin(factorial[n - r], (1000000007) - 2)) % (1000000007);
  return (int)mul;
}
long long x[100000];
long long S[100001];
long long fp[100001];
int main() {
  int N;
  long long ans = 0;
  cin >> N;
  for (int i = 0; i < (N); i++) cin >> x[i];
  set_factorial(N);
  for (int i = (0); i <= (N); i++) {
    if (i == 0)
      S[i] = factorial[0];
    else
      S[i] = (S[i - 1] + factorial[i]) % (1000000007);
  }
  for (int i = (0); i <= (N - 2); i++)
    fp[i] = ((long long)factorial[i] * (long long)factorial[N - 2 - i]) %
            (1000000007);
  for (int i = 0; i < (N - 1); i++) {
    long long add = 0;
    for (int j = 0; j < (N - 1 - i); j++) {
      add = (add + (fp[N - 2 - j] *
                    (long long)combination(N - 2 - i, N - 2 - i - j)) %
                       (1000000007)) %
            (1000000007);
    }
    add = (add * (long long)(x[N - 1] - x[i])) % (1000000007);
    ans = (ans + add) % (1000000007);
  }
  cout << ans << endl;
  return 0;
}
