#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<iomanip>
#include<sstream>
#include<list>
#include<iterator>
#include<queue>
#include<stack>
#include<utility>
#include<stdio.h>

#define ll long long
#define ull unsigned long long
#define pi acos(-1)
#define el cout<<"\n";
#define pb push_back
#define f1(n)        for (ll i = 1; i <= n; i++)
#define f0(n)        for (ll i = 0; i < n; i++)
#define fo(s, n)     for (ll i = s; i <= n; i++)


using namespace std;


//**************  MY CODE STARTS HERE  **************************//
ull gcd(ull a,ull b)
{
    if(!(b%a)) return a;
    
    return gcd(b%a,a);
}
long long ncr(int n, int r)
{
 
    long long p = 1, k = 1;

    if (n - r < r)
        r = n - r;
 
    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;

            long long m = gcd(p, k);
 
            p /= m;
            k /= m;
 
            n--;
            r--;
        }

    }
    else
        p = 1;

        return p;
}
 

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+n);
      
        int s1=0,s2=0,st1=0,st2=0;
        ull total=0;
        for(int i=0;i<n-2;i++)
        {
            s1=i;
            if(i !=0 && arr[i]==arr[i-1])continue;
            for(int j=i+1;j<n;j++)
            {
                if(arr[j]-arr[i]<=2)
                {
                    st1=j;
                }
                else
                {
                    break;
                }
            }
            if((st1-s1+1)>=3)
            total+=ncr((st1-s1+1),3);
            
            if(s1!=0 && (st2-s1+1)>=3)
            {
                total-=ncr((st2-s1+1),3);
            }
            st2=st1;
            s2=s1;
        }
    
        cout<<total<<endl;
    }
    
    return 0;
}
