#include <bits/stdc++.h>
using namespace std;
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)(1e9) + 7;
using pii = pair<long long, long long>;
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  for (long long i = (0); i < (v.size()); i++)
    for (long long j = (0); j < (v[i].size()); j++) {
      if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
        cerr << "INF";
      } else
        cerr << v[i][j];
      cerr << (j == v[i].size() - 1 ? '\n' : ' ');
    }
  cerr << endl;
}
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <long long MOD>
struct ModInt {
  static const long long Mod = MOD;
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) {
    long long sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  ModInt(signed long long sig) {
    long long sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  long long get() const { return (long long)x; }
  ModInt &operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const {
    signed a = x, b = MOD, u = 1, v = 0;
    while (b) {
      signed t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    if (u < 0) u += MOD;
    ModInt res;
    res.x = (unsigned)u;
    return res;
  }
};
template <long long MOD>
ostream &operator<<(ostream &os, const ModInt<MOD> &m) {
  return os << m.x;
}
template <long long MOD>
istream &operator>>(istream &is, ModInt<MOD> &m) {
  signed long long s;
  is >> s;
  m = ModInt<MOD>(s);
  return is;
};
template <long long MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
  ModInt<MOD> r = 1;
  while (k) {
    if (k & 1) r *= a;
    a *= a;
    k >>= 1;
  }
  return r;
}
using mint = ModInt<1000000007>;
long long modlog(long long g, long long a) {
  unordered_map<long long, long long> M;
  long long n = sqrt(mint::Mod);
  long long cur = 1;
  for (long long i = 0; i < n; i++, (cur *= g) %= mint::Mod) {
    M[cur] = i;
  }
  long long gn = cur;
  long long gn_inv = mint(gn).inverse().get();
  cur = 1;
  long long num = 0;
  while (1) {
    long long x = a * cur % mint::Mod;
    if (M.count(x)) return num + M[x];
    cur = cur * gn_inv % mint::Mod;
    num += n;
  }
}
long long modlog(long long g, mint a) { return modlog(g, a.get()); }
vector<mint> fact, factinv;
void nCr_compute_factinv(long long N) {
  N = min(N, mint::Mod - 1);
  fact.resize(N + 1);
  factinv.resize(N + 1);
  fact[0] = 1;
  for (long long i = (1); i < (N + 1); i++) fact[i] = fact[i - 1] * i;
  factinv[N] = fact[N].inverse();
  for (long long i = N; i >= 1; i--) factinv[i - 1] = factinv[i] * i;
}
mint nCr(long long n, long long r) {
  if (n >= mint::Mod)
    return nCr(n % mint::Mod, r % mint::Mod) *
           nCr(n / mint::Mod, r / mint::Mod);
  return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}
mint nHr(long long n, long long r) { return r == 0 ? 1 : nCr(n + r - 1, r); }
mint catalan(long long n) { return nCr(2 * n, n) / (n + 1); }
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  long long N;
  cin >> N;
  if (N > 2 * 1e3) return 0;
  nCr_compute_factinv(2 * N);
  vector<long long> x(N);
  for (long long i = (0); i < (N); i++) {
    cin >> x[i];
  }
  mint ans;
  for (long long i = (0); i < (N); i++) {
    for (long long j = (i + 1); j < (N); j++) {
      ;
      ;
      ;
      auto c = fact[N - 1] * fact[j - i - 1] / fact[j - i + 1 - (j == N - 1)];
      ans += c * (x[j] - x[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
