#include <bits/stdc++.h>
using namespace std;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % 1000000007 + 1000000007) % 1000000007) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= 1000000007) x -= 1000000007;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += 1000000007 - a.x) >= 1000000007) x -= 1000000007;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= 1000000007;
    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(1000000007 - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
void solve(void) {
  long long N;
  cin >> N;
  vector<long long> data(N);
  for (long long i = 0; i < N; i++) {
    cin >> data[i];
  }
  vector<mint> vec(N);
  for (long long i = 0; i < N - 1; i++) {
    vec[i + 1] = data[i + 1] - data[i];
  }
  mint ANS;
  ANS.x = 0;
  mint MUL;
  MUL.x = 1;
  for (long long i = 1; i < N; i++) {
    mint NUM;
    NUM.x = 0;
    MUL.x = 1;
    for (long long j = 1; j < N; j++) {
      mint B;
      B = j;
      if (i != j) MUL *= B;
    }
    for (long long j = 1; j <= i; j++) {
      mint A;
      A = j;
      NUM += MUL * A;
    }
    ANS += NUM * vec[i];
  }
  long long ANS1 = ANS.x;
  cout << ANS1 % 1000000007 << endl;
  return;
}
int32_t main(int32_t argc, const char* argv[]) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
  return 0;
}
