#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
ll mod = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = A[0] + 1;
    rep(i,N-1) ans = (ans * (A[i + 1] - A[i] + 1)) % mod;
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}
#ifndef LOCAL
#define debug(...)
#endif

const int MaxA = 200;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<ll> cnt(MaxA * 2 + 1);
	rep(i,n) ++(cnt[a[i] + MaxA]);
	ll ans = 0;
	for (int i = -MaxA; i <= MaxA; ++i) {
		for (int j = -MaxA; j < i; ++j) {
			ll x = i-j;
			ans += cnt[i+MaxA] * cnt[j+MaxA] * x * x;
		}
	}
	cout << ans << '\n';
}

