AtCoder ABC177 C.Sum of product of pairs
\[\sum_{i=1}^{N-1}\sum_{j=i+1}^NA_iA_j=\sum_{i=1}^NA_i*(A_{i+1}+\cdots+A_N)
\]
const int N=2e5+10;
int a[N];
LL sum[N];
int n;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum[i]=sum[i-1]+a[i];
}
int res=0;
for(int i=1;i<=n;i++)
{
int t=(sum[n]-sum[i])%mod;
res=(res+(LL)a[i]*t)%mod;
}
cout<<res<<endl;
//system("pause");
return 0;
}