N = gets.to_i
x = gets.split.map(&:to_i)
y = (0..N - 2).to_a.map { |i| x[i + 1] - x[i]}
q = []
head = -1
sum = 0

(N - 1).step(by: -1, to: 1) do |i|
  if i == N - 1
	i.times do |j|
      choice = y[j]
      z = y.reject.with_index { |_, i| i == j }
      z[j - 1] += choice unless j == 0
      q.push([z, choice])
    end
    head = 0
  elsif i == 1
    q[head..-1].each do |que|
      sum += que[0][0] + que[1]
    end
  else
    q[head..-1].each do |que|
      i.times do |j|
        choice = que[0][j]
        z = que[0].reject.with_index { |_, i| i == j }
        z[j - 1] += choice unless j == 0
        q.push([z, que[1] + choice])
      end
    end
    head = (i + 1..N - 1).to_a.inject(:*)
  end
end
  
puts sum % (10**9 + 7)