#include <bits/stdc++.h>
using namespace std;
long long n, p, arr[100001], fact[100001], tot;
long long power(long long x, long long y) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y % 2 == 1) res = (res * x) % p;
    y /= 2;
    x = (x * x) % p;
  }
  return res;
}
long long inv(long long x) { return power(x, p - 2); }
long long ncr(long long x, long long y) {
  long long cur = fact[x];
  cur *= inv(fact[y]);
  cur %= p;
  cur *= inv(fact[x - y]);
  return cur % p;
}
long long f(long long x, long long y) {
  long long temp = x - 1;
  temp += n - 1 - y;
  long long num = y - x + 1;
  long long cur = fact[temp];
  cur *= fact[num - 2];
  cur %= p;
  cur *= ncr(temp + num, num);
  cur %= p;
  return cur;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  p = 1e9 + 7;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % p;
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      long long cur = f(i, j);
      tot += cur * (arr[j] - arr[i]);
      tot %= p;
    }
  }
  for (int i = 1; i < n; i++) {
    long long cur = fact[n - 1];
    cur *= inv(n - i);
    cur %= p;
    tot += cur * (arr[n] - arr[i]);
    tot %= p;
  }
  cout << (tot % p + p) % p;
}
