stdin.ReadLine() |> ignore
let list = stdin.ReadLine().Split() |> Array.map uint64 |> Array.toList

let calcSum list =
    let rec innerCalc list s a =
        match list with
        | h :: t -> innerCalc t (s+h) (a+s*h) 
        | [] -> a
    innerCalc list 0UL 0UL

list |> calcSum |> (%) <| 1000000007UL |> stdout.WriteLine