import Enum

defmodule Main do
  @pow1097  1000000007
  def sum_of_pair(_n,seq) do
    reduceprod1097(seq)
  end

  def reduceprod1097(list), do: reduceprod1097(list,0)
  defp reduceprod1097([],acc), do: acc
  defp reduceprod1097([head|tail],acc), do: reduceprod1097(tail,rem(head*reduce1097(tail)+acc,@pow1097))

  def reduce1097(list), do: reduce1097(list,0)
  defp reduce1097([],acc), do: acc
  defp reduce1097([head|tail],acc), do: reduce1097(tail,rem(head+acc,@pow1097))

 def main do
    n = IO.gets("") |> String.trim() |> String.to_integer
    seq = IO.read(:line) |> String.trim() |> String.split(" ") |> map(&String.to_integer/1)
    IO.puts sum_of_pair(n,seq)
 end
end