#include <bits/stdc++.h>
using namespace std;
const long long p = (1e9 + 7);
long long po(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b == 1) {
    return a;
  }
  if (b % 2 == 0) {
    long long u = po(a, b / 2);
    return (u * u) % p;
  }
  long long u = po(a, b - 1);
  return (a * u) % p;
}
long long inv(long long x) { return po(x, p - 2); }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = (n - 1); i >= 0; i--) {
    for (long long j = (i + 1); j < n; ++j) {
      if (j != (n - 1))
        ans += (inv((j - i) * (j - i + 1)) * (a[j] - a[i]));
      else
        ans += inv(j - i) * (a[j] - a[i]);
      ans %= p;
    }
  }
  for (long long i = 1; i <= (n - 1); ++i) {
    ans *= i;
    ans %= p;
  }
  cout << ans;
  return 0;
}
