#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int test;
    cin>>test;
    int hash[1000];
    while(test--){
        int n;
        cin>>n;
        int arr[n];
        
        for(int i = 0; i<n; i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<0<<endl;
            continue;
        }
        else if(n==2){
            cout<<1<<endl;
            continue;
        }
        sort(arr, arr+n);
        memset(hash, 0 , 1000);
        int count = 0;
        
        for(int i = 0; i<n-1; i++){
            for(int j = i+1; j<n; j++){
                if(hash[arr[j] - arr[i]] == 0){
                    count++;
                    hash[arr[j] - arr[i]]++;
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}
