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

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

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

=begin
1

1 1
1 2

1 1 1
1 1 2
1 2 1
1 2 2
1 1 2
1 2 3

1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 2
1 1 1 2
1 1 2 3
1 2 1 1
1 2 1 2
1 2 2 1
1 2 2 2
1 2 1 2
1 2 2 3
1 1 2 1
1 1 2 2
1 2 3 1
1 2 3 2
1 1 2 2
1 2 3 3

=end
