#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template <int64_t MOD>
struct Mint {
  int64_t v;
  Mint() { v = 0; }
  Mint(int64_t x) {
    v = x % MOD;
    if (v < 0) v += MOD;
  }
  Mint operator-() { return Mint{-v}; };
  Mint operator+(Mint x) { return Mint(v + x.v); };
  Mint operator-(Mint x) { return Mint(v - x.v); };
  Mint operator*(Mint x) { return Mint(v * x.v); };
  Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD - 2).v); };
  Mint& operator+=(Mint x) { return *this = (*this + x); };
  Mint& operator-=(Mint x) { return *this = (*this - x); };
  Mint& operator*=(Mint x) { return *this = (*this * x); };
  Mint& operator/=(Mint x) { return *this = (*this / x); };
  static Mint pow(Mint base, int64_t exp) {
    if (exp == 0) return Mint(1);
    return pow(base * base, exp / 2) * (exp & 1 ? base : Mint(1));
  }
  friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;
template <class T>
struct Counting {
  Counting(int64_t n) {
    _fact.assign(n + 1, 1);
    for (int64_t i = 1; i <= n; i++) _fact[i] = T(i) * _fact[i - 1];
  }
  T fact(int64_t n) {
    if (n < 0) return 1;
    return _fact[n];
  }
  T perm(int64_t n, int64_t k) {
    if (n < k) return 1;
    return fact(n) / fact(n - k);
  }
  T comb(int64_t n, int64_t k) {
    if (n < k) return 1;
    return fact(n) / (fact(k) * fact(n - k));
  }

 private:
  vector<T> _fact;
};
int main() {
  lint n;
  cin >> n;
  vector<lint> x(n);
  for (auto& elem : x) cin >> elem;
  Counting<mint> cnt(1e6);
  mint ans = 0;
  for (lint i = 0; i < n - 1; i++) {
    for (lint next = i + 1; next < n - 1; next++) {
      lint c = next - i + 1;
      mint cases = cnt.comb(n - 1, c) * cnt.fact(c - 2) * cnt.fact(n - 1 - c);
      ans += cases * (x[next] - x[i]);
    }
    lint next = n - 1;
    lint c = next - i;
    mint cases = cnt.comb(n - 1, c) * cnt.fact(c - 1) * cnt.fact(n - 1 - c);
    ans += cases * (x[next] - x[i]);
  }
  cout << ans << endl;
}
