n = gets.to_i
as = gets.split.map &:to_i

ts = Array.new(as.size, nil)

MOD = 10 ** 9 + 7

t = 0

(as.size - 1).downto(1){ |i|
	t = (t + as[i]) % MOD
	ts[i - 1] = t
}

sum = 0

(0...as.size - 1).each{|i|
	sum += (as[i] * ts[i]) % MOD
	sum = sum % MOD
}

puts sum
