#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 2e3 + 33, mod = 1e9 + 7;
ll dp[maxn], ov[maxn], n, a[maxn];
ll bp(ll a, ll p) {
	ll r = 1;
//	cout << a << " " << p << " ";
	while(p) {
		if(p&1) r = (r*a)%mod;
		a = (a*a)%mod;
		p>>=1;
	}
//	cout << r << "\n";
	return r;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    ll t, s = 0;
    for(int i = 0; i < n; i++) cin >>a[i];
    for(int i = 0; i < n; i++) {
    	for(int j = i+1; j < n; j++) {
    		ll t = (a[j]-a[i]);
    		if(j+1!=n){
    		(t *= bp(j-i+1, mod-2))%=mod;
    		(t *= bp(j-i, mod-2))%=mod;
    		} else {
        		(t *= bp(j-i, mod-2))%=mod;
    		}
    		s = (s+t)%mod;
    	}
    }
    for(int i = 1; i < n; i++) s = (s*i)%mod;
    cout << s;
}
