let () =
  let sum = ref 0 in
  let ans = ref 0 in
  Scanf.scanf "%d\n" @@ fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%d " @@ fun d ->
    ans := (!ans + !sum * d) mod ((int_of_float(10. ** 9.)) + 7);
    sum := (!sum + d) mod ((int_of_float(10. ** 9.)) + 7)
  done;
  Printf.printf "%d\n" (!ans mod ((int_of_float(10. ** 9.)) + 7))