#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const double eps = 1e-6;
const int N = 2e5 + 10;
const int mod = 998244353;
int n;
vector<int> a;
bool p (int val, int c1, int c2, int c3) {
for (int i = 0; i <= c1; i ++) {
for (int j = 0; j <= c2; j ++) {
if (i + j * 2 > val) continue;
if ((val - i - j * 2) % 3 != 0 ) continue;
if ((val - i - j * 2) <= 3 * c3) return 1;
}
}
return 0;
}
bool possible (int c1, int c2, int c3) {
for (int i = 0; i < a.size(); i ++) {
if(!p(a[i], c1, c2, c3)) {
return 0;
}
}
return 1;
}
void solve() {
a.clear();
cin >> n;
for (int i = 1; i<= n ;i ++) {
int t;
cin >> t;
a.push_back(t);
}
int maxv = *max_element(a.begin(), a.end());
const int MAG = 3;
int ans = 0x3f3f3f3f;
for (int c1 = 0; c1 < 3; c1 ++) {
for (int c2 = 0; c2 < 3; c2 ++) {
int c3 = max(0, (maxv - c1 - c2 ) / 3);
if(c1 + c2 * 2 + 3 * c3 < maxv) continue;
if (possible(c1, c2, c3)) {
ans = min(ans, c1 + c2 + c3);
}
}
}
cout << ans << endl;
}
int main () {
int t;
cin >> t;
while (t --) solve();
return 0;
}
因为要尽可能少,所以直接考虑用3来凑,然后余数有三种情况,0,1,2 如果是0,那么可能是1个1,1个2 如果是1,那么可能是2个1和1个2以及若干个3,或者2个2以及若干个3 如果是2,那么可能是一个2和若干个3,或者两个2以及若干个3 统计发现枚举0最多2个,1最多2个,所以暴力枚举即可