#include<bits/stdc++.h>
using namespace std; 
#define int long long

int M = 1000000007;

int mod(int a){
	return (a%M + M)%M;
}
int mul(int a, int b){
	return mod(mod(a) * mod(b));
}
int add(int a, int b){
	return mod(mod(a) + mod(b));
}
int sub(int a, int b){
	return mod(mod(a) - mod(b));
}
main(){
	int n; cin>>n;
	int a[n];
	for(auto &it : a) cin>>it;
	
	int sum=0, sum1=0;
	for(int i=0; i<n; i++){
		sum = add(sum,a[i]);
		//sum1 = add(sum1,mul(a[i],a[i]));
	}
	int ans=0;
    for(int i=0; i<n; i++){
		sum = sub(sum,a[i]);
		ans = add(ans,mul(sum,a[i]));
	}	 
	cout<<ans;
}
#include <iostream>
using namespace std;
#define MOD 1000000007

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int *A=new int[N];
    long long s=0,s2=0;
    for(int i=0;i<N;++i){
        cin>>A[i];
        s+=A[i];
        s%=MOD;
        s2+=(long long)A[i]*A[i];
        s2%=MOD;
    }
    s*=s;
    s%=MOD;
    s-=s2;
    s%=MOD;
    if(s<0){
        s+=MOD;
    }
    if(s%2==0){
        cout<<(s/2)<<endl;
    }else{
        cout<<((s+MOD)/2)<<endl;
    }
    
    delete[] A;
    return 0;
}
