rt,感觉没什么问题啊
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, x, ans, maxx, minn = 1e9;
map<int, int> mp;
int C(int k)
{
return ((k * k - k) / 2) % mod;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> x;
maxx = max(x, maxx);
minn = min(x, minn);
mp[x]++;
}
for(int i = minn; i <= maxx; i++)
{
for(int j = i; j <= maxx; j++)
{
if(i != j)
{
ans += ((mp[i] * mp[j] % mod) * (C(mp[i + j]) % mod)) % mod;
}
else
{
ans += ((C(mp[i]) % mod) * (C(mp[i + j]) % mod)) %mod;
}
}
}
cout << ans;
return 0;
}