n = gets.to_i
x = gets.split.map(&:to_i)
mod = 1000000007
weight = [1] # n==2
if n>2
  [*3..n].each{|i|
    new_w = Array.new(i-1, weight[0])
    [*0..i-3].each {|j| new_w[j] += (i-2-j)*weight[j]}
    [*1..i-2].each {|j|
      new_w[j] += j*weight[j-1]
      new_w[j] += weight[j-1]
    }
    weight = new_w
  }
end
ans = 0
(n-1).times{|i|
  ans += (x[i+1]-x[i])*weight[i]
  ans %= mod
}
p ans
