#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
const int MOD=1e9+7;
int n,i,a[200001],t[200002]={},kq=0;
signed main()
{
cin>>n;
for(i=1;i<=n;i++) cin>>a[i];
for(i=n;i>=1;i--) t[i]=(t[i+1]+a[i])%MOD;
for(i=1;i<=n;i++)
{
kq=(kq+(a[i]*t[i+1])%MOD)%MOD;
// cout<<kq<<endl;
}
cout<<kq;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpbnQgbG9uZyBsb25nIAojZGVmaW5lIGVuZGwgIlxuIgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTU9EPTFlOSs3OwppbnQgbixpLGFbMjAwMDAxXSx0WzIwMDAwMl09e30sa3E9MDsKc2lnbmVkIG1haW4oKQp7CgljaW4+Pm47Cglmb3IoaT0xO2k8PW47aSsrKSBjaW4+PmFbaV07Cglmb3IoaT1uO2k+PTE7aS0tKSB0W2ldPSh0W2krMV0rYVtpXSklTU9EOwoJZm9yKGk9MTtpPD1uO2krKykKCXsKCQlrcT0oa3ErKGFbaV0qdFtpKzFdKSVNT0QpJU1PRDsgCi8vCQljb3V0PDxrcTw8ZW5kbDsKCX0KCWNvdXQ8PGtxOwp9