#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#define int long long
typedef long long ll;
using namespace std;
typedef pair<int,int> PII;
const int N=1e6+5;
int a[N];
int cnt[10]={0,7,27,41,49,63,78,108};
signed main()
{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int sum=0;
for(int i=1;i<=n;i++){
cin >> a[i];
sum=sum+cnt[a[i]];
}
int ans=sum;
if(sum>=120){
ans=min(ans,sum-50);
ans=min(ans,sum-30);
ans=min(ans,sum-15);
cout << ans << endl;
}
else if(sum>=89){
ans=min(ans,sum-30);
ans=min(ans,sum-15);
cout << ans << endl;
}
else if(sum>=69){
ans=min(ans,sum-15);
cout << ans << endl;
}
else{
cout << ans << endl;
}
}
return 0;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#define int long long
typedef long long ll;
using namespace std;
typedef pair<int,int> PII;
signed main()
{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
cout << 6*n << " " << 3 << endl;
for(int i=1;i<=3;i++){
if(i!=1){
cout << " " ;
}
cout << i*n ;
}
cout << endl;
}
return 0;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#define int long long
typedef long long ll;
using namespace std;
typedef pair<int,int> PII;
string a;
int flag=0;
map<string,string>m;
void cal(string a){
int lena=a.length();
if(flag==1){
cout << " ";
}
if(lena==1){
cout << a << a ;
}
else if(lena==2){
cout << a ;
}
else{
if(m.find(a)!=m.end()){
cout << a[0] << m[a] ;
}
else{
if(a[0]=='z' || a[0]=='c' || a[0]=='s'){
if(a[1]=='h'){
string b="";
b=b+a[0]+a[1];
string c=a.substr(2,lena-2);
cout << m[b] << m[c];
}
else{
string b=a.substr(1,lena-1);
string d="";
d=d+a[0];
cout << m[d] << m[b] ;
}
}
else{
string b=a.substr(1,lena-1);
string d="";
d=d+a[0];
cout << m[d] << m[b] ;
}
}
}
}
void init(){
m["q"]="q";
m["iu"]="q";
m["w"]="w";
m["ei"]="w";
m["e"]="e";
m["r"]="r";
m["uan"]="r";
m["t"]="t";
m["ue"]="t";
m["y"]="y";
m["un"]="y";
m["u"]="u";
m["sh"]="u";
m["i"]="i";
m["ch"]="i";
m["o"]="o";
m["uo"]="o";
m["p"]="p";
m["ie"]="p";
m["a"]="a";
m["s"]="s";
m["ong"]="s";
m["iong"]="s";
m["d"]="d";
m["ai"]="d";
m["f"] = "f";
m["en"] = "f";
m["g"] = "g";
m["eng"] = "g";
m["h"] = "h";
m["ang"] = "h";
m["j"] = "j";
m["an"] = "j";
m["k"] = "k";
m["uai"] = "k";
m["ing"] = "k";
m["l"] = "l";
m["uang"] = "l";
m["iang"] = "l";
m["z"] = "z";
m["ou"] = "z";
m["x"] = "x";
m["ia"] = "x";
m["ua"] = "x";
m["c"] = "c";
m["ao"] = "c";
m["v"] = "v";
m["zh"] = "v";
m["ui"] = "v";
m["b"] = "b";
m["in"] = "b";
m["n"] = "n";
m["iao"] = "n";
m["m"] = "m";
m["ian"] = "m";
}
signed main()
{
init();
string s;
while(getline(cin,s)){
flag=0;
int len=s.length();
for(int i=0;i<len;i++){
if(s[i]==' ' || i == len-1){
if(i==len-1){
a=a+s[i];
}
cal(a);
flag=1;
a="";
}
else{
a=a+s[i];
}
}
cout << endl;
}
return 0;
}