#include <bits/stdc++.h>
using namespace std;
const long long p = 1e9 + 7;
long long n;
long long inv[110000];
long long ans = 0;
int main() {
  cin >> n;
  inv[1] = 1;
  for (long long i = 2; i <= n; i++) inv[i] = (p - p / i) * inv[p % i] % p;
  long long f = 0;
  long long x1, x2;
  scanf("%lld", &x1);
  for (long long i = 1; i <= n - 1; i++) {
    scanf("%lld", &x2);
    f = (f + 1) * inv[i] % p + (i - 1) * f % p * inv[i] % p;
    ans = (ans + (x2 - x1) % p * f % p) * i % p;
    x1 = x2;
  }
  cout << ans % p;
}
