There are N slimes standing on a number line. The i-th slime from the left is at position x_i.  It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}.  Niwango will perform N-1 operations. The i-th operation consists of the following procedures:    * Choose an integer k between 1 and N-i (inclusive) with equal probability.   * Move the k-th slime from the left, to the position of the neighboring slime to the right.   * Fuse the two slimes at the same position into one slime.  Find the total distance traveled by the slimes multiplied by (N-1)! (we can show that this value is an integer), modulo (10^{9}+7). If a slime is born by a fuse and that slime moves, we count it as just one slime.
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    X = list(map(int, input().split()))
    D = [0 for i in range(N)]
    for i in range(N-1):
        D[i] = abs(X[i] - X[i+1])
    ans = 0
    for i in range(1, N):
        m = (i+1)*(N-1)
        if i == N-1:
            m -= 1
        d = D[i-1]
        x = d * m
        ans += x
        ans %= 10**9+7
    print(ans)


if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline

mod = 10**9+7


def main():
    N = int(input())
    X = list(map(int, input().split()))

    r1 = [1]
    r2 = [1]
    for i in range(N-1):
        r1.append(r1[i] * (i+1) % mod)
        r2.append(r2[i] * (N-1-i) % mod)
    r2.reverse()

    ans = 0
    r = 0
    for i in range(N-1):
        r += r1[i] * r2[i+1]
        ans += (X[i+1] - X[i]) * r
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
