from collections import defaultdict
import sys
def main():
    sys.setrecursionlimit(10**9)
    def loopcalc(a,b):
        z = d[(a,b)]
        if z:
            return z
        else:
            tmp = 0
            for j in range(a+1,b):
                tmp += loopcalc(a,j)*kj[b-j-1]+loopcalc(j,b)*kj[j-a-1]
                tmp = tmp%dv
            tmp += loopcalc(a+1,b)+(x[b]-x[a])*kj[b-a-2]
            tmp = tmp%dv
            d[(a,b)] = tmp
            return tmp
    
    n = int(input())
    x = list(map(int,input().split()))
    ans = 0
    dv = 10**9+7
    kj = [1]
    for i in range(2,n+1):
        kj.append(kj[-1]*i)
    d = defaultdict(int)
    for i in range(n-1):
        d[(i,i+1)] = x[i+1]-x[i]
    ans = loopcalc(0,n-1)
    print(ans)
    
if __name__ == '__main__':
    main()