#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAXN = 4e3 + 5;
const int INF = 0x3f3f3f3f;
int a[55];
unordered_map<int, int> cnt;
int main() {
    int T; scanf("%d", &T);
    for (int cs = 1; cs <= T; ++cs) {
        cnt.clear();
        int n; scanf("%d", &n);
        int ans = 0;
        for (int i = 1; i <= n; ++i){
            scanf("%d", &a[i]);
            for (int j = 1; j < i; ++j) {
                int dt = a[i] - a[j];
                if (dt == 0) continue;
                if (++cnt[dt] == 1) ++ans;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}
