#include<stdio.h> int main() { int t,m,x; scanf("%d",&t); while(t--) { scanf("%d",&m); x=m-7; if(x>=8) printf("%d\n",x); else printf("-1\n"); } }