#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long mod = (long long)1e+9 + 7ll;
const int MAXN = 2005;
long long fact[MAXN], C[MAXN][MAXN];
int main() {
  srand(1373737);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  fact[0] = 1ll;
  for (int i = 1; i < MAXN; i++) fact[i] = (fact[i - 1] * (long long)i) % mod;
  C[0][0] = 1ll;
  for (int i = 1; i < MAXN; i++) {
    C[i][0] = 1ll;
    for (int j = 1; j < MAXN; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
  int n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long ans = 0ll;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int all = n - 1;
      int need = j - i + 1;
      if (j == n - 1) need--;
      long long cur =
          C[all][need] * fact[all - need] % mod * fact[j - i - 1] % mod;
      ans = (ans + cur * (arr[j] - arr[i]) % mod) % mod;
    }
  }
  cout << ans;
  return 0;
}
