#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using seika = string;
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;
template <int p>
struct Modint {
  int value;
  Modint() : value(0) {}
  Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}
  inline Modint &operator+=(const Modint &b) {
    if ((this->value += b.value) >= p) this->value -= p;
    return (*this);
  }
  inline Modint &operator-=(const Modint &b) {
    if ((this->value += p - b.value) >= p) this->value -= p;
    return (*this);
  }
  inline Modint &operator*=(const Modint &b) {
    this->value = (int)((1LL * this->value * b.value) % p);
    return (*this);
  }
  inline Modint &operator/=(const Modint &b) {
    (*this) *= b.inverse();
    return (*this);
  }
  Modint operator+(const Modint &b) const { return Modint(*this) += b; }
  Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
  Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
  Modint operator/(const Modint &b) const { return Modint(*this) /= b; }
  inline Modint &operator++(int) { return (*this) += 1; }
  inline Modint &operator--(int) { return (*this) -= 1; }
  inline bool operator==(const Modint &b) const {
    return this->value == b.value;
  }
  inline bool operator!=(const Modint &b) const {
    return this->value != b.value;
  }
  inline bool operator<(const Modint &b) const { return this->value < b.value; }
  inline bool operator<=(const Modint &b) const {
    return this->value <= b.value;
  }
  inline bool operator>(const Modint &b) const { return this->value > b.value; }
  inline bool operator>=(const Modint &b) const {
    return this->value >= b.value;
  }
  inline Modint inverse() const {
    assert(this->value != 0);
    int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
    while (r1) {
      int q = r0 / r1;
      r0 -= q * r1;
      swap(r0, r1);
      a0 -= q * a1;
      swap(a0, a1);
    }
    return Modint(a0);
  }
  friend istream &operator>>(istream &is, Modint<p> &a) {
    long t;
    is >> t;
    a = Modint<p>(t);
    return is;
  }
  friend ostream &operator<<(ostream &os, const Modint<p> &a) {
    return os << a.value;
  }
};
const int MOD = 1e9 + 7;
using Int = Modint<MOD>;
Int pow(Int e, long x) {
  Int res = 1, tmp = e;
  while (x > 0) {
    if (x & 1) res *= tmp;
    tmp *= tmp;
    x >>= 1;
  }
  return res;
}
inline void print() { cout << endl; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
  cout << first << ' ';
  print(rest...);
}
void solve() {
  int n;
  cin >> n;
  if (n > 2000) {
    assert(0);
  }
  akari<Int> as(n);
  for (int i = 0; i < n; i++) {
    cin >> as[i];
  }
  akari<Int> ds(n - 1), cs(n - 1);
  for (int i = 0; i < n - 1; i++) {
    ds[i] = as[i + 1] - as[i];
  }
  cs[0] = 1;
  for (int x = 0; x < n - 2; x++) {
    akari<Int> new_cs(n - 1);
    for (int j = 0; j <= x + 1; j++) {
      new_cs[j] = 1;
      if (j > 0) {
        new_cs[j] += cs[j - 1] * Int(j + 1);
      }
      new_cs[j] += cs[j] * Int(x - j + 1);
    }
    swap(cs, new_cs);
  }
  Int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += cs[i] * ds[i];
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
