#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll N;
  cin >> N;
  vector<ll> x(N);
  cin >> x;

  vector<vector<ll>> dp(2, vector<ll>(N - 1));
  dp[0][0] = 1;
  bool prev = false;
  rep(i, N - 2) {
    rep(j, i + 2) {
      dp[!prev][j] = dp[prev][0];
    }
    dp[!prev][0] = (dp[!prev][0] + dp[prev][0] * (i + 1)) % MOD;
    rep(j, 1, i + 2) {
      dp[!prev][j] = (dp[!prev][j] + dp[prev][j - 1] * (j + 1) + dp[prev][j] * (i - j + 1)) % MOD;
    }
    prev = !prev;
  }

  ll ans = 0;
  rep(i, N - 1) {
    ans = (ans + (x[i + 1] - x[i]) * dp[prev][i]) % MOD;
  }
  out(ans);
}
