n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)

f = 1
for i in 2..n-1
    f*=i
end

sum = 0
seq = 0

for i in 0..x.length-2
    seq += f/(i+1)
    sum += (x[i+1]-x[i])*seq
    sum %= 10**9+7
end

puts sum
