<Problem>
http://ntucoder.net/Problem/Details/3256
Uses Crt;
Var arr:array[1..4] of integer = (2,3,5,7);
n,i,kq,j:longint;
x,b:array[1..100] of longint;
Begin
fillchar(b,sizeof(b),0);
readln(n);
for i:=1 to n do
begin
readln(x[i]);
j:=4;
while x[i]>0 do
begin
while ((x[i]-arr[j]=1) or (x[i]-arr[j]<0)) and (j>1) do dec(j);
x[i]:=x[i]-arr[j];
inc(b[i]);
end;
if x[i]<0 then b[j]:=-1;
end;
for i:=1 to n do writeln(b[i]);
readln;
End.