package net.ipipip0129.yukicoder.no657; import java.io.*; import java.util.LinkedList; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int count = Integer.parseInt(br.readLine()); int maxSize = 4; LinkedList tet = new LinkedList<>(); tet.add(0); tet.add(0); tet.add(0); tet.add(1); for (int c = 0; c < count; c++) { int n = Integer.parseInt(br.readLine()); if (maxSize < n) { for (int i = maxSize; i < n; i++) { tet.add((tet.get(i - 1) + tet.get(i - 2) + tet.get(i - 3) + tet.get(i - 4)) % 17); } maxSize = n; } out.println(tet.get(n - 1)); } out.flush(); out.close(); br.close(); } }