#include <iostream>
#define MAX 200010
using namespace std;

long long int t, n, A[MAX], DP[MAX][105], res, a;

int main()
{
    cin >> t;
    for (int i = 0; i <= MAX - 3; i++)
    {
        DP[i][0] = 1;
        if (i <= 100)
            DP[i][i] = 1;
    }
    for (int i = 1; i <= MAX - 3; i++)
    {
        for (int j = 1; j <= min(i, 100); j++)
        {
            DP[i][j] = DP[i - 1][j] + DP[i - 1][j - 1];
        }
    }
    while (t--)
    {
        cin >> n;
        res = 0;
        for (int i = 1; i <= n; i++)
            A[i] = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> a;
            A[a]++;
        }
        for (int i = 1; i <= n; i++)
        {
            res += A[i] * DP[A[i - 1] + A[i - 2]][2];
            res += DP[A[i]][2] * DP[A[i - 1] + A[i - 2]][1];
            res += DP[A[i]][3];
        }
        cout << res << endl;
    }
    return 0;
}
