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

readIntArray ()

()
|> readIntArray
|> fun arr ->
    let iMax = arr |> Array.length |> (-) <| 1
    seq {
        for i in [ 0 .. iMax ] do
            if i < iMax then
                arr.[i + 1..]
                |> Array.sum
                |> (%)
                <| 1000000007L
                |> (*) arr.[i]
                |> (%)
                <| 1000000007L
    }
    |> Seq.reduce (fun a b -> (a + b) % 1000000007L)
    |> printfn "%d"
