n=int(input())
if n>2000:exit()
a=list(map(int,input().split()))
b=[0]
for i in range(n-1):b.append(b[-1]+a[i+1]-a[i])
mod=10**9+7
ans=0
c=[1]
for i in range(n-2):
  for j in range(len(c)):
    c[j]*=i+2
    c[j]%=mod
  c.append(i+1)
for i in range(n-1):
  m=c[-1-i]
  for j in range(i,n-1):
    ans+=m*(b[j+1]-b[i])
    ans%=mod
print(ans)