#include <bits/stdc++.h>
#define int long long
#define double long double
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define Aishik int32_t main ()
using namespace std;

int nc2 (int n) {
    return n*(n-1)/2;
}

int nc3 (int n) {
    return (n*(n-1)*(n-2))/6;
}

Aishik{
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    fastIO
    int t, test;
    //t = 1;
    cin >> t;
    for (test = 1; test <= t; test++) {
        int i, j, n, m, k, q, sum, maxm, minm, counter, flag;
        int answer = 0;
        cin >> n;
        int a[n];
        map<int, int> freq;
        set<int> s;
        for (i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
            s.insert(a[i]);
        }
        for (auto x : s) {
            answer += freq[x]*freq[x+1]*freq[x+2];            
            answer += freq[x]*nc2(freq[x+2]);            
            answer += freq[x]*nc2(freq[x+1]);           
            answer += nc2(freq[x])*freq[x+2];           
            answer += nc2(freq[x])*freq[x+1];             
            answer += nc3(freq[x]);            
        }
        cout << answer << endl << endl;
    }
    return 0;
}