import math
n = int(input())
slime = [int(x) for x in input().split()]
fct = math.factorial(n-1)
aa = 0
for a in range(n-1):
    for b in range(a+1,n):
        buf_c = b - a - 1
        buf_p = b - a + 1
        if b == n - 1:
            buf_p -= 1
        if buf_c == 0:
            buf_c = 1
        buf_sum = fct * math.factorial(buf_c) / math.factorial(buf_p)
        aa += buf_sum * (slime[b] - slime[a])

print(int(aa % 1000000007))