#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long fact(long long k) {
  long long sum = 1;
  for (long long i = 2; i <= k; i++) sum *= i;
  return sum;
}
long long fact_mod(long long k) {
  long long sum = 1;
  for (long long i = 2; i <= k; i++) sum = (sum * i) % MOD;
  return sum;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9')
    return c - '0';
  else
    return -1;
}
long long pow_mod(int a, int b) {
  long long ans = 1;
  for (int i = 0; i < b; i++) ans = (ans * a) % MOD;
  return ans;
}
long long powll(long long a, long long b) {
  long long ans = 1;
  for (long long i = 0; i < b; i++) ans = ans * a;
  return ans;
}
vector<long long> func(long long n, long long k) {
  vector<long long> vec;
  long long tmp, ptr = 0;
  vec.push_back(fact_mod(n - 1));
  for (long long i = 2; i <= n - k - 1; i++) {
    tmp = vec[ptr] / i;
    vec.push_back(vec[ptr] - tmp);
    vec[ptr] = tmp;
    ptr++;
  }
  return vec;
}
int main() {
  long long n, ans = 0;
  cin >> n;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = n - 2; i >= 0; i--) {
    vector<long long> cnt;
    cnt = func(n, i);
    for (int j = 1; i + j < n; j++) {
      ans = (ans + (((x[i + j] - x[i]) * cnt[j - 1]) % MOD)) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
