n, *x = $stdin.read.split.map(&:to_i)
m = 10**9 + 7

diff = x.each_cons(2).map { |a, b| b - a }

k = 0
l = 1
puts diff.each.with_index(1).inject(0) { |sum, (d, i)| k = (k * i + l) % m; l = l * i % m; (sum * i + d * k) % m }

