import sys
input = sys.stdin.readline


def f(N, x):
    n = 1
    for i in range(1, N):
        if i != x:
            n *= i
    return n


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] = X[i+1] - X[i]

    ans = 0
    r = 0
    mod = 10**9+7
    for i in range(1, N):
        r += f(N, i)
        r %= mod
        ans += D[i-1] * r
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
