#include <bits/stdc++.h>
using namespace std;
long long f1[2005], f2[2005];
long long n, a[2005], mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n - 1; i++) {
    f2[i] = 1;
    for (long long j = 2; j < i; j++) {
      f2[i] = f2[i] * j % mod;
    }
    for (long long j = i + 2; j < n; j++) {
      f2[i] = f2[i] * j % mod;
    }
  }
  for (long long i = 1; i < n; i++) {
    f1[i] = 1;
    for (long long j = 2; j < i; j++) {
      f1[i] = f1[i] * j % mod;
    }
    for (long long j = i + 1; j < n; j++) {
      f1[i] = f1[i] * j % mod;
    }
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      ans = ans + f2[j - i] * (a[j] - a[i]);
      ans = ans % mod;
    }
    ans = ans + f1[n - i] * (a[n] - a[i]);
    ans = ans % mod;
  }
  cout << ans;
  return 0;
}
