def A():
    N = int(input())
    index = {}
    durations = []
    for i in range(N):
        temp = input().split()
        index[temp[0]] = i
        durations.append(int(temp[1]))
    X = input()
    print(sum(durations[index[X]+1:]))

import math
def B():
    N = int(input())
    X = [int(n) for n in input().split()]
    #n_minus_one_factorial = math.factorial(N-1)
    diff = [b-a for a, b in zip(X[:-1], X[1:])]
    def process(differences):
        #print(differences)
        if len(differences) == 1:
            return differences[0]%(10**9+7)
        ans = 0
        denom = len(differences)
        fact = math.factorial(denom-1)
        for i in range(denom):
            temp = differences[:i]+differences[i+1:]
            if i > 0:
                temp[i-1] += differences[i]
            ans += (differences[i]*fact + process(temp))
        #print(ans, differences)
        return ans%(10**9+7)
    print(process(diff))

B()