open System

let Ruisekiwa list = 

    let rec subRuisekiwa accum list2 temp = 
        match list2 with
        | [] -> accum
        | hd :: tl -> subRuisekiwa ((hd + temp) :: accum) tl (hd + temp)

    subRuisekiwa [] (List.rev list) 0L |> List.tail
let Mod = 1000000007L

let N = Console.ReadLine() |> int64
let AList = Console.ReadLine().Split(' ') |> Array.map int64 |> Seq.toList

let RuisekiAList = Ruisekiwa AList

let result list =
    let rec subR accum list2 (ruisekiL:list<int64>) =
        match list2 with
        | hd :: tl when List.isEmpty tl -> accum
        | hd :: tl -> 
            printfn "%A" (accum,list2,ruisekiL)
            subR (accum + ((hd * (ruisekiL.Head)) % Mod)) tl ruisekiL.Tail
    (subR 0L list RuisekiAList) % Mod 

printfn "%i" (result AList)