MOD = 1_000_000_007_i64

n = read_line.to_i64
xs = read_line.split.map(&.to_i64)
if n > 2000
  # give up
  exit
end

facs = Array(Int64).new(n + 2, 1_i64)
n.times do |i|
  facs[i + 1] = (facs[i] * (i + 1)) % MOD
end

vs = [
  Array(Int64).new(n + 2, 0_i64),
  Array(Int64).new(n + 2, 0_i64),
]
vs[0][1] = 1_i64
1.upto(n - 1) do |i|
  1.upto(i + 1) do |j|
    a = (vs[(i - 1) % 2][j - 1] * j) % MOD
    b = (vs[(i - 1) % 2][j] * (i + 1 - j)) % MOD
    vs[i % 2][j] = (a + b + facs[i]) % MOD
  end
end

ans = 0_i64
xs.each_cons(2).with_index do |(a, b), i|
  a = ((b - a) * vs[n % 2][i + 1]) % MOD
  ans = (ans + a) % MOD
end
p ans
