#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
int main() {
  int N;
  cin >> N;
  assert(N <= 2000);
  vector<int> x(N);
  for (int i = 0; i < (N); ++i) {
    cin >> x[i];
  }
  vector<mint> k(N);
  k[0] = 1;
  for (int n = 2; n <= (N - 1); ++n) {
    mint temp = k[0];
    for (int i = 0; i < (n - 1); ++i) {
      k[i] *= n;
    }
    k[n - 1] = k[n - 2] + temp;
  }
  mint ans = 0;
  for (int i = 0; i < (N - 1); ++i) {
    ans += k[i] * (x[i + 1] - x[i]);
  }
  cout << ans.x << endl;
}
