local n=io.read("n")
local a={}
local b={[0]=0}
for i=1,n do
    a[i]=io.read("n")
    b[i]=b[i-1]+a[i]
end

local mod=1000000007
local total=0
for i=1,n-1 do
    total=total+a[i]*(b[n]-b[i])%mod
end
print(total%mod)