local read = io.read

local n = read("n")
local a = {}
for i = 1, n do
	a[i] = read("n")
end

local mod_num = 1000000007

local back_sum_t = {}
back_sum_t[n + 1] = 0
for i = n, 2, -1 do
	back_sum_t[i] = (a[i] + back_sum_t[i + 1]) % mod_num
end
local out = 0
for i = 1, n - 1 do
	out = (out + ((a[i] * back_sum_t[i + 1]) % mod_num)) % mod_num
end

print(out)
