# coding: utf-8
# Your code here!
N=int(input())
SR=list(map(int,input().split()))

l=[1]
for n in range(N-1):
    l.append(l[-1]*(n+2))
#print(l)

ans=0
are=N
for n in range(N-1):
    for m in range(n+1,N):
        ans+=l[are-m+n-1]*(SR[m]-SR[n])
    are-=1
print(ans%(10**9+7))