import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static Map dp = new HashMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); dp.put(1, 1); dp.put(2, 2); String result = IntStream.range(0, n) .mapToObj(i -> String.valueOf(dfw(sc.nextInt()))) .collect(Collectors.joining("\n")); System.out.println(result); } static int dfw(int x) { if (!dp.containsKey(x)) { int count = 0;; for (int i = 1; i * i <= x; i++) { if (x % i == 0) { if (i * i == x) { count++; } else { count += 2; } } } dp.put(x, dfw(x - count)); } return dp.get(x); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }