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

long long mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++)
    cin >> A[i];
  long long ans = 0;
  long long sum = 0;
  long long sum2 = 0;
  
  for(int i = 0; i < N; i++){
    sum2 = (sum2 + A[i]*A[i]) % (2*mod);
    sum = (sum + A[i]) % (2*mod);
  }
  
  ans = (sum*sum - sum2)  % (2*mod) / 2;
  
  cout << ans << endl;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template < typename T > using oset = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// find_by_order(k) (k+1)th largest element
// order_of_key(k) no of elements <=k

typedef long long ll;
typedef long double ld;
#define endl '\n'
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define pb push_back
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ld PI = 4*atan((ld)1);
const ll INF = LLONG_MAX;
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    repA(qq,1,tt){
        ll n; cin >> n;
        vll a(n),suf(n);
        rep(i,n){
            cin >> a[i];
        }
        suf[n-1] = a[n-1];
        repD(i,n-2,0){
            suf[i] = suf[i+1]+a[i];
        }
        ll ans =0;
        rep(i,n-1){
            // cout << a[i] << " " << suf[i] << endl;
            ans += a[i]*(suf[i+1]%mod);
            ans %=mod;
        }

        cout << ans << endl;
    }
}
