//
// Created by Dandosh on --/11/2020.
//
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MAXN = 2e5 + 5;

int main() {
    IO;
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        vector<ll> freq(n + 5);
        for (int i = 0, x; i < n; i++)
            cin >> x, freq[x]++;

        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            if (freq[i] > 2)
                ans += (freq[i] * (freq[i] - 1) * (freq[i] - 2) / 6);

            if (freq[i] > 1)
                ans += (freq[i] * (freq[i] - 1) / 2) * freq[i + 1],
                        ans += (freq[i] * (freq[i] - 1) / 2) * freq[i + 2];

            if (freq[i + 1] > 1)
                ans += (freq[i + 1] * (freq[i + 1] - 1) / 2) * freq[i];

            if (freq[i + 2] > 1)
                ans += (freq[i + 2] * (freq[i + 2] - 1) / 2) * freq[i];

            ans += freq[i] * freq[i + 1] * freq[i + 2];
        }

        cout << ans << endl;
    }

    return 0;
}