#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define MN 300005
#define MM 600005
#define ll long long
#define mod 1000000007
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
int n;
int x[MN];
int pre[MN],suf[MN],ans;
int main(){
	scanf("%d",&n);
	F(i,1,n)scanf("%d",x+i);
	pre[0]=suf[n]=1;
	F(i,1,n-1)pre[i]=(ll)pre[i-1]*i%mod;
	dF(i,n-1,1)suf[i]=(ll)suf[i+1]*i%mod;
	F(i,1,n-1)ans=(ans+(ll)(x[n]-x[i])*pre[i-1]%mod*suf[i+1])%mod;
	printf("%d\n",ans);
	return 0;
}