#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int n;
vector<long long> v;
long long binpow(long long a, long long x) {
  if (x == 0) return 1;
  if (x & 1) {
    return a * binpow(a, x - 1) % MOD;
  } else {
    long long t = binpow(a, x / 2);
    return t * t % MOD;
  }
}
long long inverse(long long x) { return binpow(x, MOD - 2); }
const int N = 2002;
long long mem[N][N];
long long go(int from, int to) {
  if (to == from) {
    return 0;
  }
  if (mem[from][to] != -1) return mem[from][to];
  long long ans = 0;
  for (int i = from; i < to; i++) {
    ans += go(from, i) + go(i + 1, to) + v[to] - v[i];
    ans %= MOD;
  }
  return mem[from][to] = ans * inverse(to - from) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      mem[i][j] = -1;
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  long long ans = go(0, n - 1);
  for (int i = 1; i < n; i++) {
    ans = ans * i % MOD;
  }
  cout << ans << endl;
  return 0;
}
