#include <bits/stdc++.h>
using namespace std;
#define LL long long;
int n;
queue <int> dl;
//该队列维护的是正在煮的四个锅(可以在煮一个的位置)
int main()
{
ios::sync_with_stdio(false); //该语句是cin和scanf具有相同的速度
int T;
cin >> T;
while (T--) {
while (!dl.empty()) dl.pop();
cin >> n;
for (int i = 1; i <= n; ++i) {
int t;
cin >> t;
while (!dl.empty() && t>= dl.front())
dl.pop();
if (int(dl.size())<4) {
dl.push(t+6);
}
else {
t = dl.front();
dl.pop();
dl.push(t+5);
}
}
cout << dl.back()<<endl;
}
return 0;
}
\