#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define MAXN 100001 
#define F first
#define S second
#define debug(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define pi acos(-1)
// __int128->GNU G++ 17 9.2.0 Codeforces (but doesnot use with cout cin And cant take direct input use normal datatype the typecast ) 
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*STUDY*/
//https://codeforces.com/blog/entry/20935
//https://www.hackerrank.com/contests/mit-open-20-finals/challenges/fractions-arent-tough-or-are-they
//
// typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;


ll power(ll x,ll y){
    if(y==0)
        return 1;
    ll res=power(x,y/2);
    res=(res*res);
    if(y&1)
        res=(res*x);
    return res;
}
ll powermod(ll x,ll y,ll mod){
    if(y==0)
        return 1;
    ll res=powermod(x,y/2,mod);
    res=(res*res)%mod;
    if(y&1)
        res=(res*x)%mod;
    return res;
}
bool isPrime(ll n){
    //There is a fact that the distance between adjacent prime numbers isn't big. For n = 10^9 maximal distanse is 282.
    //https://stackoverflow.com/questions/31216097/given-n-And-k-return-the-kth-permutation-sequence
    if(n<2)
        return false;
    for(ll i=3;i*i<=n;i+=2)
        if(n%i==0)return false;
    return true;
}
void factors(int n,vector<int> &fact){
  vector<int> fact1;
  for(int i=1;i*i<=n;i++)
  {
    if(n%i==0){
      fact.pb(i);
      if(n/i!=i)
      fact1.pb(n/i);
    }
  }
  for(int i=fact1.size()-1;i>=0;i--)
    fact.pb(fact1[i]);
}

  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
/*nCr*/
ll nCr(int n,int r){
    if(n<r || r<0)return 0;
    ll ans=1;
    for(int i=1,j=n-r+1;i<=r;i++,j++) ans=ans*j/i;
    return ans;
}

ll modInverse(ll a, ll m) 
{ 
    a = a % m; 
    for (ll x = 1; x < m; x++) 
        if ((a * x) % m == 1) 
            return x; 
    return -1;
}

void solve(){
    ll n,m,k;
    cin>>n;m=3;k=2;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll l=lower_bound(a,a+n,a[i]-k)-a;
        if((i-l)<2)continue;
        ans=ans+(i-l-1)*(i-l)/2;
    }
    cout<<ans<<endl;
}
int main(){ 
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //sieve();
    int test=1; 
    cin>>test;
    for(int i=1;i<=test;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}
