#include <stdio.h>
#include <string.h>
#define max(a,b) (a)>(b)?(a):(b)
int main(){
int x,realage,i;
int t;
scanf("%d",&t);
while (t--){
scanf("%d",&realage);
for (x=2;;x++){
if (realage<=8){
printf("-1\n");
break;
}
else if (realage==7+x){
if(x>=8)
printf("%d\n",x);
else
printf("-1\n");
break;
}
}
}
return 0;
}