#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>
 
using namespace std;

typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  reverse(all(v));
  ll p = v[0];
  ll m = MOD-v[0];
  ll dp = 1;
  ll dm = 1;
  rep(i,1,v.sz){
    ll dp1 = (dp+dm)%MOD;
    ll dm1 = dp;
    ll p1 = (p+m+v[i]*dp1%MOD)%MOD;
    ll m1 = (MOD+p-v[i]*dm1%MOD)%MOD;
    p = p1;
    m = m1;
    dp = dp1;
    dm = dm1;
  }
  cout << p%MOD << endl;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll a[401];
    for(int i = 0; i < 401; ++i){
        a[i] = 0;
    }
    for(int i = 0; i < n; ++i){
        ll tmp;
        cin >> tmp;
        ++a[tmp+200];
    }

    ll sum = 0;
    for(int i = 0; i < 401; ++i){
        for(int j = i; j < 401; ++j){
            sum += a[i]*a[j]*(i-j)*(i-j);
        }
    }
    cout << sum << endl;
    return 0;
}