#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
  x *= f;
  return;
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
int n;
long long a[100010];
long long b[100010];
long long ans = 0;
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  b[1] = 1;
  for (int i = 2; i <= n - 1; i++) {
    long long tot = 0;
    for (int j = 1; j <= i - 1; j++) tot += b[j], tot %= 1000000007;
    for (int j = 1; j <= i - 1; j++) b[j] *= i, b[j] %= 1000000007;
    b[i] = b[1] + tot, b[i] %= 1000000007;
  }
  for (int i = 1; i <= n - 1; i++)
    ans += b[i] * (a[i + 1] - a[i]), ans %= 1000000007;
  cout << ans << endl;
  return 0;
}
