(* Examples *)
(*
stdin.ReadLine()
printfn "%d"
printfn "%s"
*)

(* Library *)
module Library = ()

(* Standard Input *)
let readSplit elementFun=
  stdin.ReadLine().Split()
  |> Array.map elementFun

let read elementFun =
  stdin.ReadLine() |> elementFun

let readMap H =
  [|for i in 1..H -> stdin.ReadLine()|]
  |> Array.map(fun line ->
    line.ToCharArray()
  )
  |> array2D

(* Main *)
open Library

let N = read int
let A = readSplit int64
let m = pown 10L 9 + 7L

[|0..N - 2|] 
|> Array.fold (fun sumi i ->
  (
    sumi + (
      [|i + 1..N - 1|]
      |>Array.fold (fun sumj j ->
        (sumj + (A.[i] ^^^ A.[j])) % m
      ) 0L
    )
  ) % m
) 0L
|> printfn "%d"