#include <bits/stdc++.h>
const long long mod = 1000000007;
long long modinv(long long a, long long modVal) {
  long long b = modVal, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  u %= modVal;
  if (u < 0) u += modVal;
  return u;
}
long long frac(long long n) {
  long long v = 1;
  while (n > 1) {
    v *= n;
    v %= mod;
    n--;
  }
  return v;
}
long long nCr(const long long n, const long long r) {
  return (frac(n) * modinv((frac(r) * frac(n - r)) % mod, mod)) % mod;
}
long long solve(const std::vector<long long> x) {
  const int n = x.size();
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      const long long mid = j - i - 1;
      const long long left = i;
      const long long right = n - j - 1;
      const long long right_removable = ((right - 1) > 0 ? (right - 1) : 0);
      const long long removable = left + right_removable;
      const long long outer = left + right;
      for (int k = 0; k <= removable; k++) {
        const long long remain = removable - k + ((j != n - 1) ? 1 : 0);
        long long sumDist =
            (x[j] - x[i]) * frac(mid + k) * nCr(removable, k) * frac(remain);
        ans += sumDist;
        ans %= mod;
      }
    }
  }
  return ans;
}
int main(int argc, char *argv[]) {
  int n;
  std::vector<long long> x;
  long long ans;
  std::cin >> n;
  x.resize(n);
  for (int i = 0; i < n; i++) {
    std::cin >> x[i];
  }
  ans = solve(x);
  std::cout << ans << std::endl;
  return 0;
}
