#include <bits/stdc++.h>
using namespace std;
using Lint = long long;
template <int mod>
class ModInt {
 private:
  Lint val;

 public:
  Lint value() { return val; }
  ModInt(Lint x = 0) { val = x % mod; }
  ModInt pow(int n) {
    ModInt res(1), x(val);
    while (n > 0) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  ModInt inv() { return pow(mod - 2); }
  ModInt& operator+=(ModInt rhs) {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  ModInt& operator-=(ModInt rhs) {
    val += mod - rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  ModInt& operator*=(ModInt rhs) {
    val = val * rhs.val % mod;
    return *this;
  }
  ModInt& operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }
  ModInt operator+(ModInt rhs) { return ModInt(val) += rhs; }
  ModInt operator-(ModInt rhs) { return ModInt(val) -= rhs; }
  ModInt operator*(ModInt rhs) { return ModInt(val) *= rhs; }
  ModInt operator/(ModInt rhs) { return ModInt(val) /= rhs; }
};
using mint = ModInt<1000000007>;
template <typename T>
class BiCoef {
 public:
  vector<T> fact, ifact, inv;
  BiCoef(int N) : fact(N + 1), ifact(N + 1), inv(N + 1) {
    fact[0] = ifact[N] = inv[0] = 1;
    for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i;
    ifact[N] /= fact[N];
    for (int i = N - 1; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1);
    for (int i = 1; i <= N; i++) inv[i] = ifact[i] * fact[i - 1];
  }
  T comb(int n, int k) {
    if (n < 0 or k < 0 or n < k) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < N; i++) cin >> x[i];
  BiCoef<mint> bc(N + 1);
  mint ans = 0;
  for (int i = 0; i < N - 1; i++)
    for (int j = i + 1; j < N; j++) {
      mint k = bc.fact[N - 1] / (mint)(j - i);
      if (j < N - 1) k /= (mint)(j - i + 1);
      ans += k * (x[j] - x[i]);
    }
  cout << ans.value() << endl;
  return 0;
}
