#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll randGen(ll lower, ll upper) {return (rand() % (upper - lower + 1)) + lower;}
ll dir[4][2] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);

//******************               DEBUG             **********************//
template<typename F, typename S>
ostream& operator << (ostream &out, const pair<F, S>&p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
ostream& operator << ( ostream &out, const vector<T> &v) {
	out << "[";
	typename vector<T> :: const_iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		if (it != v.begin()) out << ", ";
		out << *it;
	}
	return out << "]";
}
template<typename T>
ostream& operator << (ostream &out, const set<T> &v) {
	out << "[";
	typename set<T> :: const_iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		if (it != v.begin()) out << ", ";
		out << *it;
	}
	return out << "]";
}
template<typename T>
ostream& operator << (ostream &out, const unordered_set<T> &v) {
	out << "[";
	typename unordered_set<T> :: const_iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		if (it != v.begin()) out << ", ";
		out << *it;
	}
	return out << "]";
}
template<typename F, typename S>
ostream& operator << (ostream &out, const map<F, S> &v) {
	out << "[";
	typename map<F, S> :: const_iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		if (it != v.begin()) out << ", ";
		out << it->first << ":" << it->second;
	}
	return out << "]";
}
template<typename F, typename S>
ostream& operator << (ostream &out, const unordered_map<F, S> &v) {
	out << "[";
	typename unordered_map<F, S> :: const_iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		if (it != v.begin()) out << ", ";
		out << it->first << ":" << it->second;
	}
	return out << "]";
}
#define deb(x) cout << #x << ": " << x << "\n";

//****************************************************************************//

void test_case() {
	ll n;
	cin >> n;
	vector<ll> b(n);
	ll mx = 0;
	for (ll i = 0; i < n; i++) {
		cin >> b[i];
		mx = max(mx, b[i]);
	}
	vector<ll> a(mx + 5);
	for (ll i = 0; i < n; i++) {
		a[b[i]]++;
	}
	ll ans = 0;
	// deb(a);
	for (ll i = 1; i <= mx; i++) {
		if (a[i] > 0) {
			if (a[i] >= 2) {
				ans += ((a[i] * (a[i] - 1) * (a[i] - 2)) / 6);
				if (a[i + 1] > 0)
					ans += (((a[i] * (a[i] - 1)) / 2) * a[i + 1]);
				if (a[i + 2] > 0)
					ans += (((a[i] * (a[i] - 1)) / 2) * a[i + 2]);
			}
			if (a[i + 1] > 1) {
				ans += (a[i] * ((a[i + 1] * (a[i + 1] - 1)) / 2));
			}
			if (a[i + 2] > 1) {
				ans += (a[i] * ((a[i + 2] * (a[i + 2] - 1)) / 2));
			}
			if ((a[i + 1] > 0) && (a[i + 2] > 0)) {
				ans += (a[i] * a[i + 1] * a[i + 2]);
			}
		}
		// deb(i); deb(ans);
	}
	cout << ans << endl;

}


int main()
{
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	cin >> t;
	while (t-- > 0) {
		test_case();
	}
	return 0;
}

