import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	enum long Mod = 10L ^^ 9L + 7L;
	auto n = readln.chomp.to!size_t;
	auto a = new long[n];
	auto s = new long[n];

	long ss;
	foreach (i;0..n) {
		long x;
		readf(" %s", &x);
		a[i] = x;
		s[i] = ss;
		ss = (ss + x) % Mod;
	}

	long total;

	foreach (size_t i, e;a) {
		total = (total + s[i] * e) % Mod;
	}

	writeln(total);
}
