#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (1e+9)+7;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  ll sm = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    sm = (sm + a[i]) % MOD;
  }
  ll ans = 0;
  for(int i=0; i<n; i++){
    sm -= a[i];
    if(sm < 0) sm += MOD;
    ans = (ans + (a[i] * (sm)) % MOD) % MOD;
  }
  cout << ans << endl;
}
#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;
}