let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

readIntArray ()

()
|> readIntArray
|> Array.indexed
|> fun arr ->
    [ for (i1, v1) in arr do
        for (i2, v2) in arr do
            if i1 < i2 then v1 * v2 ]
    |> List.sum
    |> (%)
    <| 1000000007L
    |> printfn "%d"
