#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long powmod(long long a, long long l, long long md) {
  long long res = 1;
  while (l) {
    if (l & 1) res = res * a % md;
    l /= 2;
    a = a * a % md;
  }
  return res;
}
long long binpow(long long a, long long l) {
  long long res = 1;
  while (l) {
    if (l & 1) res = res * a;
    l /= 2;
    a = a * a;
  }
  return res;
}
long long __set(long long b, long long i) { return b | (1 << i); }
long long __unset(long long b, long long i) { return b & (~(1UL << i)); }
long long __check(long long b, long long i) { return b & (1 << i); }
long long mulmod(long long a, long long b, long long md) {
  return ((a % md) * (b % md)) % md;
}
long long addmod(long long a, long long b, long long md) {
  return (a + b) % md;
}
long long submod(long long a, long long b, long long md) {
  return (((a - b) % md) + md) % md;
}
long long divmod(long long a, long long b, long long md) {
  return mulmod(a, powmod(b, md - 2, md), md);
}
const long long inf = 0xFFFFFFFFFFFFFFFL;
priority_queue<long long, vector<long long>, greater<long long> > pq;
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long getRand(long long l, long long r) {
  uniform_int_distribution<long long> uid(l, r);
  return uid(rng);
}
long long md = 1e9 + 7;
void manacher(vector<long long>& d1, vector<long long>& d2, long long n,
              string& s) {
  for (long long i = 0, l = 0, r = -1; i < n; i++) {
    long long k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);
    while (0 <= i - k && i + k < n && s[i - k] == s[i + k]) k++;
    d1[i] = k--;
    if (i + k > r) {
      l = i - k;
      r = i + k;
    }
  }
  for (long long i = 0, l = 0, r = -1; i < n; i++) {
    long long k = (i > r) ? 0 : min(d2[l + r - i + 1], r - i + 1);
    while (0 <= i - k - 1 && i + k < n && s[i - k - 1] == s[i + k]) k++;
    d2[i] = k--;
    if (i + k > r) {
      l = i - k - 1;
      r = i + k;
    }
  }
}
long long f[(long long)(4e5 + 10)];
long long rf[(long long)(4e5 + 10)];
long long C(long long l, long long k, long long md) {
  if (k < 0 || k > l) {
    return 0;
  }
  return f[l] * rf[k] % md * rf[l - k] % md;
}
void precfac() {
  f[0] = 1;
  for (long long i = 1; i < (long long)(4e5 + 10); i++) {
    f[i] = f[i - 1] * i % MOD;
  }
  rf[(long long)(4e5 + 10) - 1] =
      powmod(f[(long long)(4e5 + 10) - 1], MOD - 2, MOD);
  for (long long i = (long long)(4e5 + 10) - 2; i >= 0; i--) {
    rf[i] = rf[i + 1] * (i + 1) % MOD;
  }
}
signed main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  precfac();
  long long n;
  cin >> n;
  vector<long long> x(n);
  long long ans = 0;
  for (long long i = 0; i < n; i++) cin >> x[i];
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      if (j == n - 1) {
        long long tp =
            ((((x[j] - x[i]) * (C(n - 1, j - i, md) * (f[j - i - 1])) % MOD) %
              MOD) *
             f[n - 1 - (j - i)]) %
            MOD;
        ans = (ans + tp) % MOD;
      } else {
        long long tp = ((((x[j] - x[i]) *
                          (C(n - 1, j - i + 1, md) * (f[j - i - 1])) % MOD) %
                         MOD) *
                        f[n - 1 - (j - i + 1)]) %
                       MOD;
        ans = (ans + tp) % MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
