#include<stdio.h> int main(void) { int T,A,x; scanf("%d",&T); while(T--) { scanf("%d",&A); if(A>14) { x=A-7; printf("%d\n",x); } else printf("-1\n"); } return 0; }