#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> x(n);
	for(int i = 0; i < n; i++) scanf("%lld", &x[i]);

	const int MOD = 1e9 + 7;
	auto inverse = [&](i64 x) {
		i64 n = MOD - 2, ret = 1;
		while(n) {
			if(n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	};

	std::vector<i64> fact(n + 1, 1), inv(n + 1);
	for(i64 i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * i % MOD;
	for(int i = 0; i < n + 1; i++) inv[i] = inverse(fact[i]);
	
	if(n <= 2000) {
		i64 ans = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				int k = j - i + 1;
				i64 dist = x[j] - x[i];

				if(j == n - 1) {
					(ans += fact[n - 1] * inv[k - 1] % MOD * fact[k - 2] % MOD * dist % MOD) %= MOD;
				} else {
					(ans += fact[n - 1] * inv[k] % MOD * fact[k - 2] % MOD * dist % MOD) %= MOD;
				}
			}
		}

		printf("%lld\n", ans);
	} else {
		std::abort();
	}
	return 0;
}
