#include <bits/stdc++.h>
using namespace std;
const int md = (int)1e9 + 7;
inline int add(int x, int y) {
  x += y;
  if (x > md) {
    x -= md;
  }
  return x;
}
inline int mul(int x, int y) { return (int)((long long)x * y % md); }
inline int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) {
      res = mul(res, x);
    }
    x = mul(x, x);
    y >>= 1;
  }
  return res;
}
inline int inv(int x) { return power(x, md - 2); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  const int N = (int)1e5 + 10;
  vector<int> fact(N);
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  auto C = [&](int n, int k) {
    if (k < 0 || k > n) {
      return 0;
    }
    return mul(fact[n], mul(inv(fact[k]), inv(fact[n - k])));
  };
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long s = 0;
  vector<long long> ps(n);
  ps[0] = 0;
  for (int i = 1; i < n; i++) {
    ps[i] = ps[i - 1] + a[i] - a[i - 1];
  }
  auto Get = [&](int l, int r) { return ps[r] - ps[l]; };
  int ans = 0;
  for (int d = 1; d < n; d++) {
    int sum = 0;
    for (int i = d; i < n - 1; i++) {
      sum = add(sum, Get(i - d, i));
    }
    for (int k = 0; k < n - d - 1; k++) {
      int x = mul(C(n - d - 2, k), mul(fact[k + d - 1], fact[n - k - d - 1]));
      ans = add(ans, mul(x, sum));
    }
  }
  for (int x = 1; x < n; x++) {
    int sum = Get(x - 1, n - 1);
    for (int k = 0; k < x; k++) {
      int y = mul(C(x - 1, k), mul(fact[n - x - 1 + k], fact[x - k - 1]));
      ans = add(ans, mul(sum, y));
    }
  }
  cout << ans << '\n';
  return 0;
}
