#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b) {
  long long r = 1LL;
  while (b) {
    if (b & 1LL) r *= a;
    if (r >= 1000000007) r %= 1000000007;
    a *= a;
    if (a >= 1000000007) a %= 1000000007;
    b >>= 1LL;
  }
  return r % 1000000007;
}
long long fact[100100];
long long rfact[100100];
long long nCr(long long n, long long r) {
  long long ret = 1LL;
  ret *= fact[n];
  ret %= 1000000007;
  ret *= rfact[r];
  ret %= 1000000007;
  ret *= rfact[n - r];
  ret %= 1000000007;
  return ret;
}
int main() {
  memset((fact), (0), sizeof(fact));
  fact[0] = 1;
  for (long long i = (1); i < (100100); ++i) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= 1000000007;
  }
  memset((rfact), (0), sizeof(rfact));
  rfact[0] = 1;
  for (long long i = (1); i < (100100); ++i) {
    rfact[i] = rfact[i - 1] * modpow(i, 1000000007 - 2);
    rfact[i] %= 1000000007;
  }
  long long n;
  cin >> n;
  if (n > 2000) return 0;
  vector<long long> v;
  for (long long i = (0); i < (n); ++i) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  long long ans = 0;
  for (long long i = (0); i < (v.size()); ++i) {
    for (long long j = (i + 1); j < (v.size()); ++j) {
      long long d = v[j] - v[i];
      long long a = j - i - 1;
      long long b = j - i + 1;
      if (j == n - 1) b--;
      long long c = n - 1 - b;
      long long ans1 = fact[a] * fact[c];
      ans1 %= 1000000007;
      ans1 *= nCr(n - 1, c);
      ans1 %= 1000000007;
      ans1 *= d;
      ans1 %= 1000000007;
      ans += ans1;
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
