#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int age;
cin>>age;
if(age<=14){
printf("-1\n");continue;
}
int res=-1;
for(int i=2;i<1000;i++){
if(i*1+7==age){
res=i;break;
}
}
cout<<res<<endl;
}
return 0;
}