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) % 1000000007UL) ((a+s*h) % 1000000007UL)
        | [] -> a % 1000000007UL
    innerCalc list 0UL 0UL

list |> calcSum |> stdout.WriteLine