#include <bits/stdc++.h>
using namespace std;
const long MOD = 1000000000 + 7;
int main() {
  int N, A1, A2, A3;
  long x[100001], wa;
  long long kai[100001], Ksum[100001], result = 0;
  cin >> N;
  kai[0] = Ksum[0] = 1;
  for (int i = 1; i <= N; i++) {
    cin >> x[i];
    kai[i] = (kai[i - 1] * i) % MOD;
    Ksum[i] = (kai[i] + Ksum[i - 1]) % MOD;
  }
  if (N == 2) {
    cout << x[2] - x[1];
    return 0;
  }
  for (int i = 1; i <= N - 2; i++) {
    for (int j = i + 1; j <= N - 1; j++) {
      if (i == 1)
        A1 = 0;
      else
        A1 = i - 1;
      if (j == i + 1)
        A2 = 0;
      else
        A2 = j - i - 1;
      A3 = N - j - 1;
      if (A2 > 0)
        wa = (Ksum[A1 + A2 + A3] - Ksum[A2 - 1]) % MOD;
      else
        wa = Ksum[A1 + A2 + A3] % MOD;
      if (wa < 0) wa = (wa + MOD) % MOD;
      result += ((long long int)(x[j] - x[i]) * wa) % MOD;
      result %= MOD;
    }
  }
  result += (long long int)(x[N] - x[1]) * kai[N - 2] % MOD;
  result %= MOD;
  result += (long long int)(x[N] - x[N - 1]) * Ksum[N - 2] % MOD;
  result %= MOD;
  for (int i = 2; i <= N - 2; i++) {
    wa = (Ksum[N - 2] - Ksum[N - i - 2]) % MOD;
    if (wa < 0) wa = (wa + MOD) % MOD;
    result += ((long long int)(x[N] - x[i]) * wa) % MOD;
    result %= MOD;
  }
  cout << result;
  return 0;
}
