require 'openssl'
N = gets.to_i
X = gets.split.map &:to_i
D = 10**9+7
i = 1.to_bn
m = i-1
F = (2...N).inject(i) {|s,i| s.mod_mul(i,D)}
p (0...N).inject {|s,n|
  m += F * n.to_bn.mod_inverse(D)
  (m*(X[n]-X[n-1])+s)%D}.to_i