#include <bits/stdc++.h>
using namespace std;
long long aa[200000], bb[200000], cc[2000000];
void t() {
  aa[0] = aa[1] = 1;
  bb[0] = bb[1] = 1;
  cc[1] = 1;
  for (long long i = 2; i < 200000; i++) {
    aa[i] = aa[i - 1] * i % 1000000007;
    cc[i] = 1000000007 - cc[1000000007 % i] * (1000000007 / i) % 1000000007;
    bb[i] = bb[i - 1] * cc[i] % 1000000007;
  }
}
long long calc(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return aa[n] * (bb[k] * bb[n - k] % 1000000007) % 1000000007;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long x[n];
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    x[i] = x[i + 1] - x[i];
  }
  long long ans = 0;
  long long mp[n];
  t();
  long long dp[n - 1];
  for (long long i = 0; i < n - 1; i++) {
    long long a = calc(n - 1, 2 + i);
    long long b = 1, c = 1;
    for (long long j = 0; j < n - i - 3; j++) {
      b *= (j + 1);
      b %= 1000000007;
    }
    for (long long j = 0; j < i; j++) {
      c *= (j + 1);
      c %= 1000000007;
    }
    a %= 1000000007;
    if (a == 0)
      a = b;
    else
      a *= b;
    a % 1000000007;
    a *= c;
    a %= 1000000007;
    dp[i] = a;
  }
  for (long long i = 0; i < n - 1; i++) {
    long long num = 0;
    for (long long j = 0; j < n - 1 - i; j++) {
      num += x[i + j];
      long long num2 = num * dp[j] % 1000000007;
      num2 %= 1000000007;
      ans += num2;
      ans %= 1000000007;
      if (j == (n - 2 - i) && j != 0) {
        dp[j - 1] += dp[j];
        dp[j - 1] %= 1000000007;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
