/* * ******************************************************************************************** * AUTHOR : Vijju123 * * Language: C++14 * * Purpose: - * * IDE used: Codechef IDE. * ******************************************************************************************** * Comments will be included in practice problems if it helps ^^ */ #include #include using namespace std; int main() { // your code goes here #ifdef JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t; cin>>t; assert(t>=1 and t<=10); while(t--) { int n; cin>>n; assert(n>=1 and n<=100000); int arr[n]; int freq[2500]={0}; for(int i=0;i>arr[i]; assert(-1000<=arr[i] and arr[i]<=1000); arr[i]+=1000;//Make numbers non-negative freq[arr[i]]++; } int i,j; long long ans=0; for(i=0;i<=2000;i++) { for(j=0;j<=2000;j++) {//Check for all pairs (a,b) if((i+j)%2==0 and freq[(i+j)/2] and freq[i] and freq[j]) { if(i!=j) ans+=1LL*freq[i]*freq[j]; else ans+=1LL*(freq[i]-1)*freq[j];//Formulas as discussed in editorial. } } } ans>>=1; cout<