#include<iostream>
#include<fstream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
int main(){
int T,A,X,temp;
cin>>T;
while(T--){
temp=-1;
cin>>A;
for(X=8;X<=300;X++){
if(X+7==A){
temp=X;
break;
}
}
cout<<temp<<endl;
}
return 0;
}