open Printf
open Scanf

let prn s x = printf "%s %d\n" s x

let num () = scanf "%d" (fun x -> x)
let num1 () = scanf "%d\n" (fun x -> x)
let num2 () = scanf "%d %d\n" (fun x y -> (x, y))
let num3 () = scanf "%d %d %d\n" (fun x y z -> (x, y, z))

let numN n =
  let rec loop rs k =
    if k=n then
      List.rev rs
    else
      let x = scanf " %d" (fun x -> x) in
      loop (x::rs) (k+1)
  in
  if n=0 then
    []
  else if n=1 then
    [num ()]
  else
    loop [num ()] 1

let () =
  let m = 1000000007 in
  let n = num1 () in
  let xs = numN n in
  let s = List.fold_left
            (fun s x -> (s + x) mod m) 0 xs in
  let s2 = (s * s) mod m in
  let d =
    List.fold_left
      (fun s x -> (s + (x * x)) mod m)
      0 xs
  in
  let rec loop x =
    if x < d then loop (x+m) else x
  in
  let s2 = loop s2 in
  let r = (s2 - d) mod (2 * m) in
  let r = r / 2 in
  printf "%d\n" r

