#include <bits/stdc++.h>

using namespace std;
int64_t mod = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int64_t>arr(n);
    for(auto & i : arr)
        cin >> i;
    vector<int64_t>sufsum;
    sufsum.push_back(0);
    for(int i = n-1; i > 0; --i){
        auto a = sufsum.back();
        a+=arr[i];
        sufsum.push_back(a);
    }
    reverse(sufsum.begin(),sufsum.end());
    int64_t ans = 0;
    for(int i = 0 ; i < n; ++i){
        ans+=(arr[i]*(sufsum[i]%mod));
        ans%=mod;
    }
    cout << ans << "\n";
    return 0;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n;
    scanf("%lld",&n);
    ll a[n+1];
    ll sum=0;
    for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);	
		sum=(sum+a[i])%mod;
	} 
	ll ans=0;
	for(int i=1;i<n;i++){
		sum=(sum+mod-a[i])%mod;
		ans=(ans+a[i]*sum)%mod;
	}
	cout<<ans%mod<<endl;
}