#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (long long i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (long long i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << *it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << it->first << "->" << it->second << "> ";
  }
  return s << endl;
}
template <class T>
void show(vector<T> v) {
  for (long long i = 0; i < v.size(); i++) {
    cerr << v[i] << " ";
  }
  cerr << "\n";
}
long long x[100010];
const long long MAX = 510000;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> x[i];
  COMinit();
  long long cnt = 0;
  vector<long long> kai(n - 1);
  long long ka = 1;
  kai[0] = 1;
  for (long long i = 1; i < n; i++) {
    ka *= i;
    ka %= MOD;
    kai[i] = ka;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      long long tmp1, tmp2, tmp3;
      if (j != n - 1) {
        tmp1 = (x[j] - x[i]) * kai[j - 1 - i];
        tmp1 %= MOD;
        tmp2 = COM(n - 1 - (j - 1 - i), n - 1 - (j - i + 1)) *
               kai[n - 1 - (j - i + 1)];
        tmp2 %= MOD;
        cnt += tmp1 * tmp2;
        cnt %= MOD;
      } else {
        tmp1 = (x[j] - x[i]) * kai[j - 1 - i];
        tmp1 %= MOD;
        tmp2 = COM(n - 1 - (j - 1 - i), i) * kai[i];
        tmp2 %= MOD;
        cnt += tmp1 * tmp2;
        cnt %= MOD;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
