#include <bits/stdc++.h>
using lli = long long int;
using pii = std::pair<int, int>;
void VintOut(std::vector<int>& A) {
  const int n = A.size();
  if (n == 0) {
    putchar('\n');
    return;
  }
  printf("%d", A[0]);
  for (int i = 1; i < n; ++i) printf(" %d", A[i]);
  putchar('\n');
}
void VintOut(std::vector<long long int>& A) {
  const int n = A.size();
  if (n == 0) {
    putchar('\n');
    return;
  }
  printf("%lld", A[0]);
  for (int i = 1; i < n; ++i) printf(" %lld", A[i]);
  putchar('\n');
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline bool bitUP(int state, int k) { return (state >> k) & 1; }
inline bool bitUP(long long int state, int k) { return (state >> k) & 1; }
namespace MyFunc {
using LLi = long long int;
using ULLi = unsigned long long int;
inline LLi gcd(LLi a, LLi b) {
  while (b != 0) {
    a %= b;
    std::swap(a, b);
  }
  return a;
}
inline LLi lcm(LLi a, LLi b) { return (a * b) / MyFunc::gcd(a, b); }
inline LLi power(LLi a, LLi n) {
  LLi res = 1LL, waiting = a;
  while (n != 0LL) {
    if ((n & 1LL) != 0LL) res *= waiting;
    waiting *= waiting;
    n >>= 1;
  }
  return res;
}
inline LLi power_mod(LLi a, LLi n, LLi mod_number___ = 1e9 + 7) {
  LLi res = 1LL, waiting = a;
  while (n != 0LL) {
    if ((n & 1LL) != 0LL) {
      res *= waiting;
      res %= mod_number___;
    }
    waiting *= waiting;
    waiting %= mod_number___;
    n >>= 1;
  }
  return res;
}
inline LLi inverse_mod(LLi a, LLi mod_number___ = 1e9 + 7) {
  return MyFunc::power_mod(a, mod_number___ - 2);
}
inline LLi inverse_mod_euclid(LLi a, LLi mod_number___ = 1e9 + 7) {
  LLi b = mod_number___, u = 1, v = 0;
  while (b != 0) {
    LLi t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  u %= mod_number___;
  if (u < 0) u += mod_number___;
  return u;
}
}  // namespace MyFunc
constexpr int mod = 1e9 + 7;
std::vector<int> X;
int main(void) {
  int n;
  scanf("%d", &n);
  X.resize(n);
  for (int(i) = (0); (i) < (n); ++(i)) scanf("%d", &X[i]);
  lli res = 0;
  for (int(i) = (0); (i) < (n); ++(i)) {
    for (int j = i + 1; j < n; ++j) {
      lli a1 = MyFunc::inverse_mod(j - i);
      lli a2 = (j == n - 1) ? 1 : MyFunc::inverse_mod(j - i + 1);
      lli b = (a1 * a2) % mod;
      (res += (X[j] - X[i]) * b) %= mod;
    }
  }
  for (int x = 1; x < n; ++x) (res *= x) %= mod;
  printf("%lld\n", res);
  return 0;
}
