/*
  Created by: Amit Kumar at 21:46 on 16 Dec 20
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define S(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
  {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  ll ans = 0;
  for (ll i = 0; i < n - 2; i++)
  {
    ll k = lower_bound(arr + i + 2, arr + n, arr[i]) - arr;
    ll m = upper_bound(arr + i + 2, arr + n, arr[i] + 2) - arr;
    ll t = m - i - 2;
    ll p = k - i - 1;
    //cout << t << " " << p << "\n";
    if (t >= p)
      ans += ((t) * (t + 1)) / 2 - ((p - 1) * (p)) / 2;
  }
  cout << ans << "\n";
}
int main()
{
#ifdef WIN32
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#endif
  int t;
  t = 1;
  cin >> t;
  for (int I = 1; I <= t; I++)
  {
    solve();
  }
  return 0;
}