from collections import deque
import itertools
class dist:
    def __init__(self,X,N):
        self.S = [0]*(N)
        l = list(range(N-1))
        for i in range(N-1):
            self.S[i+1] = self.S[i] + X[i+1] -X[i]
        self.L = itertools.permutations(l,N-1)

    def dist(self,left,right):
        return self.S[right]-self.S[left]

delta = 1000000007
N = int(input())
X = list(map(int,input().split()))
d = dist(X,N)
ans = 0
for l in d.L:
    slime = [1]*N
    for i in l:
        for j in range(i+1,N):
            if slime[j] == 1:
                ans += d.dist(i,j)
                if ans > delta:
                    ans = ans%delta
                slime[i] = 0
                break
print(ans)