N = gets.chomp.to_i
X = gets.chomp.split.map(&:to_i)
X.unshift(0)

$ans = 0
def k(x, n) # 次のやつとの距離
  x[n+1] - x[n]
end

def dis(x, n)
  if n == N-1
    $ans += k(x, 1)
    return
  end
  1.upto(N-n) do |i|
    $ans += k(x, i)
    xx = x.dup
    xx.delete_at(i)
    dis(xx, n+1)
  end
end

dis(X, 1)

p $ans % (10**9 + 7)
