let as_num_list s =
  let splitted = String.split_on_char ' ' s in
  List.map int_of_string splitted

(* 累積和を作る *)
let rec make_cumulative_sum sum_a a_list = match a_list with
    [] -> []
  | first :: rest -> (sum_a - first) :: make_cumulative_sum (sum_a - first) rest
  
let find_sum_of_product_of_pairs a_list cumulative_sum =
  List.fold_left2
    (fun acc x y-> (acc + x * y) mod 1000000007)
    0
    a_list
    cumulative_sum

let main () =
  let _ = Scanf.sscanf (read_line ()) "%d" (fun x -> x) in (* nは飛ばす *)
  let as_str = read_line () in
  let a_list = as_num_list as_str in
  let sum_a = List.fold_left (fun acc x -> x + acc) 0 a_list in
  let cumulative_sum = make_cumulative_sum sum_a a_list in
  let ans = find_sum_of_product_of_pairs a_list cumulative_sum in
  (
    Printf.printf "%d" ans;
    print_newline ()
  )

let _ = main ()
