// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/23/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename T, T MOD>
class modint {
 private:
  T val_;

 public:
  constexpr modint() : val_(0) {}
  constexpr modint(T v) : val_(v%MOD) {}
  constexpr modint& operator=(T v) { val_ = v%MOD; return *this; }

  constexpr T val() const { return val_; }
  constexpr modint operator+(modint x) const { return (val() + x.val())%MOD; }
  constexpr modint operator+=(modint x) { return *this = *this + x; }
  constexpr modint operator++() { return *this += 1; }
  constexpr modint operator++(int) { modint c = *this; ++(*this); return c; }
  constexpr modint operator-(modint x) const { return (val() + MOD - x.val())%MOD; }
  constexpr modint operator-=(modint x) { return *this = *this - x; }
  constexpr modint operator--() { return *this -= 1; }
  constexpr modint operator--(int) { modint c = *this; --(*this); return c; }
  constexpr modint operator*(modint x) const { return (val() * x.val())%MOD; }
  constexpr modint operator*=(modint x) { return *this = *this * x; }
  friend constexpr modint pow(modint x, T p) {
    modint t = 1;
    modint u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr modint operator/(modint x) const { return *this * pow(modint{x}, MOD-2); }
  constexpr modint operator/=(modint x) { return *this = *this / x; }

  constexpr bool operator==(modint x) const { return val() == x.val(); }
  constexpr bool operator!=(modint x) const { return val() != x.val(); }
  constexpr bool operator<(modint x) const { return val() < x.val(); };
  constexpr bool operator<=(modint x) const { return val() <= x.val(); };
  constexpr bool operator>(modint x) const { return val() > x.val(); };
  constexpr bool operator>=(modint x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, modint x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, modint& x) {
    return is >> x.val_;
  }

};

template <typename T, T MOD, T MAX>
class combination {
 public:
  using mint = modint<T, MOD>;
 private:
  vector<mint> fact_;
  vector<mint> ifact_;

 public:
  constexpr combination() {
    fact_.resize(MAX+1);
    fact_[0] = 1;
    for (size_t i = 1; i <= MAX; ++i) {
      fact_[i] = fact_[i-1] * i;
    }
    ifact_.resize(MAX+1);
    ifact_[MAX] = mint(1)/fact_[MAX];
    for (int i = MAX-1; i >= 0; i--) {
      ifact_[i] = ifact_[i+1] * (i+1);
    }
  }

  mint fact(size_t i) const { return fact_[i]; }
  mint ifact(size_t i) const { return ifact_[i]; }

  mint operator()(T p, T q) const {
    return fact_[p] * ifact_[q] * ifact_[p-q];
  }

};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  using combination = combination<unsigned long long, (unsigned long long)1e9+7, (unsigned long long)1e5>;
  combination cmb;
  using mint = combination::mint;

  int N; cin>>N;
  vector<ll> X(N); for (auto& x : X) cin>>x;
  if (N == 2) {
    cout << X[1]-X[0] << endl;
  } else {

    mint ans = 0;
    for (int i = 0; i < N-1; i++) {
      for (int j = i+1; j < N; j++) {
        auto u = j-i-1;
        if (j < N-1) {
          auto p = mint(X[j]-X[i]) * cmb.fact(u) * cmb.fact(N-u-3) * cmb(N-1, u+2);
          ans += p;
        } else {
          auto p = mint(X[j]-X[i]) * cmb.fact(u) * cmb.fact(N-u-2) * cmb(N-1, u+1);
          ans += p;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
