import math
n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(1,n-i):
        f=math.factorial(j-1)
        ff=math.factorial(i+1)
        d=x[i+j]-x[i]
        ans=(ans+d*f*ff)%(1e+9+7)
print(int(ans))