import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    // writeln(a);
    auto s = new long[](n + 1);
    s[1] = a[0];
    foreach (i; 0 .. n)
    {
        s[i + 1] = s[i] + a[i];
    }
    // writeln(s);
    long ans;
    long mod = (10 ^^ 9) + 7;
    long aj;
    foreach (i; 0 .. n)
    {
        // writeln(a[i], "  ", s[n] - s[i + 1]);
        a[i] %= mod;
        aj = s[n] - s[i + 1];
        aj %= mod;
        ans += a[i] * aj;
        ans %= mod;

    }
    writeln(ans % mod);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
