# include <stdio.h>
int main()
{
int t = 0,n,array[100],p = 0,j = 0,s;
scanf("%d ",&t);
s = t;
for(;t;--t)
{
scanf("%d",&n);
p = j;
for(int i = 8;i <1000;++i)
{
if((7 + i ) == n)
{
array[j] = i;
++j;
break;
}
}
if(p == j)
{
array[j] = -1;
++j;
}
}
for(int m = 0;m <s;++m)
{
printf("%d\n",array[m]);
}
}