/*#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;

#define  CIN            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define  ll             long long int
#define  pb             push_back
#define  ull            unsigned long long int
#define  pii            pair < ll, ll>
#define  pll            pair < ll, pii>
#define  ff             first
#define  ss             second
#define  mx4            1000005
#define  MOD            1000000007
#define  mod2           1000000009
#define  min3(a,b,c)    min(a,min(b,c))
#define  min4(a,b,c,d)  min(d,min(a,min(b,c)))
#define  max3(a,b,c)    max(a,max(b,c))
#define  max4(a,b,c,d)  max(d,max(a,max(b,c)))
#define  ms(a,b)        memset(a,b,sizeof(a))
#define  mpp            make_pair
#define  gcd(a, b)      __gcd(a,b)
#define  lcm(a, b)      ((a)*(b)/gcd(a,b))
#define  input          freopen("input.txt","rt", stdin)
#define  output         freopen("output.txt","wt", stdout)
#define  PI             2*acos(0.0)
#define  zero(a)        memset(a,0,sizeof a)
#define  all(a)         a.begin(),a.end()
#define  rall(a)        a.rbegin(),a.rend()
#define  rev(a)         reverse(all(a))
#define  upper(s)       transform(s.begin(),s.end(),s.begin(), ::toupper)
#define  lower(s)       transform(s.begin(),s.end(),s.begin(), ::tolower)
#define  Unique(X)      (X).erase(unique(all(X)),(X).end())
#define  MX             200005
#define  nl             '\n'
#define  yes            cout<<"YES"<<endl
#define  no             cout<<"NO"<<endl
#define  fix(x)         cout<<fixed<<setprecision(x)
#define  coutv(v)       for(auto it:v)cout<<it<<space;cout<<nl;
#define  cinv(v)        for(auto &it:v)cin>>it;
#define  Case(x)        cout<<"Case "<<x<<": "
#define  strtoint(a)    atoi(a.c_str())
#define  dbg(x)         cerr<<#x<<" is "<<x<<'\n';
#define  fix(x)         cout<<fixed<<setprecision(x)
#define  leastonepos(x) __builtin_ffs(x)
#define  leadingoff(x)  __builtin_clz(x)
#define  trailingoff(x) __builtin_ctz(x)
#define  numofone(x)    __builtin_popcount(x)
#define  error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

///Compute_phi_co_prime
/*void computeTotient(int n){ll phi[n+5];for (int i=1; i<=n; i++)phi[i] = i;for (int p=2; p<=n; p++)
{if (phi[p] == p){phi[p] = p-1;for (int i = 2*p; i<=n; i += p){phi[i] = (phi[i]/p) * (p-1);}}}}*/
///seieve
/*vector<bool>mark(100000004);vector<int>prm;void sieve(int x){mark[0]=mark[1]=1;
for(int i =4; i<=x; i=i+2)mark[i]=1;for(int i=3; i*i<=x; i+=2)if(!mark[i])
for(int j=i*i; j<=x; j+=2*i)mark[j]=1;prm.push_back(2);for(int i=3; i<=x; i+=2)
if(mark[i]==0)prm.push_back(i);}*/
///PrimeFactorization
/*vector<int>pf;void primeFact(ll n){for(int i=0; i<prm.size()&&prm[i]*prm[i]<=n; i++)
{if(n%prm[i]==0){while(n%prm[i]==0){n=n/prm[i] ;pf.push_back(prm[i]);}}}if(n>1)pf.push_back(n);}*/
///power
/*ll pow( ll base , ll val ){ll res = 1 ;for(int i = 1 ; i <= val ; i++ ){res *= base ;}return res ;}*/
///Fibonacci
/*ll fib[ 100005 ] ;fib[ 1 ] = 1 ;fib[ 2 ] = 2 ;
for( int i = 3 ; i <= 100000 ; i ++ ){ fib[ i ] = ( fib[ i - 1 ] + fib[ i - 2 ] ) % MOD ;}*/
//min_dis(character)
/*ll min_dis(char ch1,char ch2){ll x = abs(ch1-ch2);return min(x,26-x);}*/
///leap_year
/*inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }*/
///BinToDec
/*ll BinToDec(bitset<64>bs)
{ll sum = 0 ,lim=bs.size();for( int i = 0 ; i <= lim ; i ++ )sum += bs2[ i ] * pow( 2, i ) ;return sum ;}*/
///Multiplication_With_Mod
/*long long fun(long long a, long long b){long long res = 0;a %= MOD;while (b)
{if (b & 1)res = (res + a) % MOD;a = (2 * a) % MOD;b >>= 1;}return res;}*/
///power of two
/*ll Pow[65];void power_of_two(){Pow[0]=1;
for(int i = 1 ; i <= 60 ; i++) Pow[i]=Pow[i-1]*2ll;}*/
///---------------Order set-------------------
///*os.find_by_order(index) os.order_of_key(value)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
orderset<ll>os ;*/
/*ll Os_Bound(ll x , ll UpOrLow)
{if(UpOrLow==2) x++;ll pos = os.order_of_key(x);if (pos == os.size()) return -1;else return *(os.find_by_order(pos));}*/

///priority_queue<int,vector<int>,greater<int> >pq;
///string s5 = "abcdefghijklmnopqrstuvwxyz";
///string s6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
///int days [14] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
///string month[14]= {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------
void err(istream_iterator<string> it)
{
    cerr<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << " | ";
    err(++it, args...);
}
/*int Set(int N,int pos){return N=N | (1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int reset(int N,int pos){return N= N & ~(1<<pos);}*/
/*
/*ll bigmod(ll a , ll b , ll m)
{
    if(b==0) return 1;
    if(b&1) return (a%m * bigmod(a,b-1,m))%m;
    ll x = bigmod(a,b/2,m);
    return (x*x)%m;
}
ll inverse(ll a , ll b , ll m)
{
    return ((a%m)*bigmod(b,m-2,m)%m);
}*/
/*
set<ll>st;
set<ll>::reverse_itertor it ;
for( it = rbegin() ; it!=st.rend() ; it++)
st.erase(next(it).base());
set<ll>::iterator it ;
for( it = begin() ; it!=st.end() ; it++)
st.erase(it);
*/
/*
struct data{
    ll wt,iq,indx;
    bool operator <(const data &other) const{
        if (wt==other.wt) return iq>other.iq;
        return wt<other.wt;
    }
}ara[1005];
*/

vector<ll>v1,v2,v3,v4;
///vector<pii>v5;
string s1, s2, s3;
///map<ll,ll>mp;
///map<ll,ll>::iterator it;
///ll ara[100005];
///multiset<ll>ms;
///multiset<ll>::iterator it;
///set<ll>st;
///set<ll>::iterator it;

int main()
{
    CIN;
    ll  a,b,c,d,e,f,i,j,k,m,n,cnt1=0,cnt2=0,sum1=0,sum2=0,chk1=0,chk2=0,T=1;
    cin>> T ;
    while(T--)
    {
        v1.clear();
        cin >> a ;
        for( i = 0 ; i < a ; i++)
        {
            cin >> b ;
            v1.pb(b);
        }
        sort(all(v1));
        ll ans = 0 ;
        for( i = 0 ; i < a ; i++)
        {
            ll x = upper_bound(all(v1),v1[i]+2)-v1.begin();
            if(x-i>=2)
            {
                ll ex = x-i;
                ex-=2;
                ex=(ex*(ex+1))/2;
                ans+=ex;

            }
        }
        cout<<ans<<endl;

    }
    return 0 ;
}
///printf & cout ekshatey use korbo nah
