N = gets.to_i
A = gets.chomp.split.map(&:to_i)

ans = 0
h = {}
0.upto(N-2) do |i|
  (i+1).upto(N-1) do |j|
    if h.key?([A[i], A[j]])
      ans += h.key?([A[i], A[j]])
    elsif h.key?([A[j], A[i]])
      ans += h.key?([A[j], A[i]])
    else
      h[[A[i], A[j]]] = A[i].modulo(10**9+7) * A[j].modulo(10**9+7)
      h[[A[j], A[i]]] = h[[A[i], A[j]]]
      ans += h[[A[j], A[i]]]
    end
    ans = ans.modulo(10**9+7)
  end
end

puts ans