def main():
    n = int(input())
    x = list(map(int,input().split()))
    ans = 0
    dv = 10**9+7
    kj = [1,1]
    for i in range(2,n+1):
        kj.append(kj[-1]*i)
    for i in range(n):
        for j in range(n):
            if i > j:
                for k in range(j+1,i):
                    ans += (x[k]-x[j])*kj[i-k-1]*kj[k-j-1]
                    ans = ans % dv
                ans += kj[i-j-1]*(x[i]-x[j])
                ans = ans % dv
    print(ans)
    
if __name__ == '__main__':
    main()