#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int exgcd(int a, int b, int& x, int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int d = exgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
inline long long inv(int i) {
  int x, y;
  exgcd(i, mod, x, y);
  return (x + mod) % mod;
}
int a[maxn];
long long fac[maxn];
int main() {
  int n;
  cin >> n;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    fac[i] = fac[i - 1] * i % mod;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int l = j - i + 1;
      if (j == n)
        ans = (ans + fac[n - 1] * inv(l - 1) % mod * (a[j] - a[i]) % mod) % mod;
      else
        ans = (ans +
               fac[n - 1] * inv(l) % mod * inv(l - 1) % mod * (a[j] - a[i])) %
              mod;
    }
  cout << ans << endl;
}
