#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=3e5+5;
ll a[MAXN];
ll cn[MAXN];
ll vis[MAXN];
int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll all=(n*(n-1)*(n-2))/6;
        ll cnt=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            cn[a[i]]++;
        }
        sort(a+1,a+n+1);
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[a[i]])vis[a[i]]=i;
            int index=(upper_bound(a+1, a + n+1, a[i]+2) - a);
            if(index==n+1)break;
            else
            {
                if(index-i<2) {
                    index++;
                }
                if(index!=n+1)
                ans+=(index - i-1) * (n+1 - index)+((n+1-index)*(n-index))/2;
            }
        }
        cout<<all-ans<<endl;
    }
}