#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
template <typename T>
T npow(T x, ll n) {
  T ans = T(1);
  while (n != 0) {
    if (n & 1) ans = ans * x;
    x = x * x;
    n = n >> 1;
  }
  return ans;
}
class mint {
 private:
  ll _num, _mod = mod;
  mint set(ll num) {
    _num = num;
    if (_num < 0) {
      if (_num >= -_mod)
        _num = _mod + _num;
      else
        _num = _mod - (-_num) % _mod;
    } else if (_num >= _mod)
      _num %= _mod;
    return *this;
  }
  ll imod() const {
    ll n = _mod - 2;
    ll ans = 1, x = _num;
    while (n != 0) {
      if (n & 1) ans = ans * x % _mod;
      x = x * x % _mod;
      n = n >> 1;
    }
    return ans;
  }

 public:
  explicit mint() { _num = 0; }
  explicit mint(ll num) {
    _num = num;
    if (_num < 0) {
      if (_num >= -_mod)
        _num = _mod + _num;
      else
        _num = _mod - (-_num) % _mod;
    } else if (_num >= _mod)
      _num %= _mod;
  }
  explicit mint(ll num, ll M) {
    _mod = M;
    _num = num;
    if (_num < 0) {
      if (_num >= -_mod)
        _num = _mod + _num;
      else
        _num = _mod - (-_num) % _mod;
    } else if (_num >= _mod)
      _num %= _mod;
  }
  mint(const mint &cp) {
    _num = cp._num;
    _mod = cp._mod;
  }
  mint operator+(const mint &x) const { return mint(_num + x._num, _mod); }
  mint operator-(const mint &x) const { return mint(_num - x._num, _mod); }
  mint operator*(const mint &x) const { return mint(_num * x._num, _mod); }
  mint operator/(const mint &x) const { return mint(_num * x.imod(), _mod); }
  mint operator+=(const mint &x) { return set(_num + x._num); }
  mint operator-=(const mint &x) { return set(_num - x._num); }
  mint operator*=(const mint &x) { return set(_num * x._num); }
  mint operator/=(const mint &x) { return set(_num * x.imod()); }
  mint operator=(const ll x) { return set(x); }
  mint operator+(const ll x) const { return *this + mint(x, _mod); }
  mint operator-(const ll x) const { return *this - mint(x, _mod); }
  mint operator*(const ll x) const { return *this * mint(x, _mod); }
  mint operator/(const ll x) const { return *this / mint(x); }
  mint operator+=(const ll x) {
    *this = *this + x;
    return *this;
  }
  mint operator-=(const ll x) {
    *this = *this - x;
    return *this;
  }
  mint operator*=(const ll x) {
    *this = *this * x;
    return *this;
  }
  mint operator/=(const ll x) {
    *this = *this / x;
    return *this;
  }
  bool operator==(const mint &x) const { return _num == x._num; }
  bool operator!=(const mint &x) const { return _num != x._num; }
  friend mint operator+(ll x, const mint &m) {
    return mint(m._num + x, m._mod);
  }
  friend mint operator-(ll x, const mint &m) {
    return mint(x - m._num, m._mod);
  }
  friend mint operator*(ll x, const mint &m) {
    return mint(m._num * (x % m._mod), m._mod);
  }
  friend mint operator/(ll x, const mint &m) {
    return mint(m.imod() * (x % m._mod), m._mod);
  }
  explicit operator ll() { return _num; }
  explicit operator int() { return (int)_num; }
  friend std::ostream &operator<<(std::ostream &os, const mint &x) {
    os << x._num;
    return os;
  }
  friend std::istream &operator>>(std::istream &is, mint &x) {
    ll val;
    is >> val;
    x.set(val);
    return is;
  }
};
ll inv_mod(ll a, ll _mod) { return (ll)npow(mint(a, _mod), _mod - 2); }
class Factorial {
 private:
  vector<ll> fac;
  vector<ll> ifac;

 public:
  Factorial(ll N) {
    fac.push_back(1);
    for (int i = 0, i_len = int(N); i < i_len; ++i)
      fac.push_back(fac[i] * (i + 1) % mod);
    ifac.resize(N + 1);
    ifac[N] = inv_mod(fac[N], mod);
    for (int i = 0, i_len = int(N); i < i_len; ++i)
      ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
  }
  ll fact(ll a) { return fac[a]; }
  ll ifact(ll a) { return ifac[a]; }
  ll cmb(ll a, ll b) {
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0 || b < 0) return 0;
    ll tmp = ifact(a - b) * ifact(b) % mod;
    return tmp * fac[a] % mod;
  }
  ll per(ll a, ll b) {
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0 || b < 0) return 0;
    return fac[a] * ifac[a - b] % mod;
  }
};
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = 0, i_len = int(N); i < i_len; ++i) cin >> x[i];
  Factorial get(N);
  mint ans(0);
  for (int i = 0, i_len = int(N - 1); i < i_len; ++i)
    for (int j = 0, j_len = int(i + 1); j < j_len; ++j) {
      if (i + 1 - j <= N - j - 1)
        ans += mint(get.fact(N - i - 2)) * get.per(i, j) *
               get.per(N - j - 2, i - j) * (x[N - 1] - x[j]);
    }
  cout << ans << endl;
}
