# import numpy as np
# import math
import sys
input = sys.stdin.readline


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

    mod = 10 ** 9 + 7

    res = 0
    frac = 1
    sum = 0

    for i in range(N-1):
        diff = x[i+1] - x[i]
        sum += 1 / (i+1)
        frac *= i + 1
        frac %= mod
        res += diff * sum
        res %= mod

    res *= frac
    res %= mod
    res = int(res)

    print(res)



main()
