import random
n = int(input())
x = list(map(int,input().split()))

d = 0
count = n
res = 0
while count != 1:
    for i in range(0,n):
        cho = n - i + 1
        Z = []
        for j in range(1,cho+1):
            Z.append(j)
        k = random.choice(Z)
        for t in range(k+1,n):
            if x[t] != 0:
                x[t] += x[k]
                x[k] = 0
                d += x[t] - x[k]
        res += d/len(Z)
    count -= 1

b = 1
for h in range(1,n):
    b *= h

if b*res < 10**9+7:
    print(int((b*res)))
else:
    print(int((b*res)%10**9+7))