#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a[200000],ans,mod = 1000000007ll,cnt[7000],mx;
signed main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
mx = max(mx,a[i]);
cnt[a[i]]++;
}
for(int i = 2; i <= mx; i++){
if(cnt[i] < 2) continue;
int x = (cnt[i] - 1) * cnt[i] / 2 % mod;
for(int j = 1; j <= i / 2; j++){
if(j == i - j){
if(cnt[j] > 1)
ans += x * cnt[j] * (cnt[j] - 1) / 2 % mod;
}else{
if(cnt[j] > 0 && cnt[i - j] > 0)
ans += x * cnt[j] * cnt[i - j] % mod;
}
}
}
cout << ans;
return 0;
}
前三个测试点AC,其他WA,不调完不睡觉