#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cnt[200010], n, sum;
 
int main(){
    int t;
    cin>>t;
    while(t--){
        cin>>n;
        sum=0;
        int a;
        for(int i=1;i<=n+5;i++)
            cnt[i]=0;
        for(int i=0;i<n;i++){
            cin>>a;
            cnt[a]++;
        }
        ll ans=0;
        for(int i=1;i<=n-2;i++){
            ll x=cnt[i];
            ll y=cnt[i+1];
            ll z=cnt[i+2];
            ans+=x*y*z;
        }
        for(int i=1;i<=n-1;i++){
            ll x=cnt[i];
            ll y=cnt[i+1];
            ll z=cnt[i+2];
            ll xx=x*(x-1)/2;
            ll yy=y*(y-1)/2;
            ll zz=z*(z-1)/2;
            ans+=xx*y+yy*x+xx*z+x*zz;
        }
        for(int i=1;i<=n;i++){
            ll x=cnt[i];
            ll xx=x*(x-1)*(x-2)/6;
            ans+=xx;
        }
        cout<<ans<<'\n';
    }
}