import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 0 ; i < n ; i++){ int cnt = constructPrimeNumbers(sc.nextInt()); System.out.println(cnt); } } private static int constructPrimeNumbers(int maxNumber) { int cnt = 0; boolean[] targetNumbers = new boolean[maxNumber + 1]; Arrays.fill(targetNumbers, true); targetNumbers[0] = false; targetNumbers[1] = false; int sqrt = (int) Math.sqrt(maxNumber); for (int i = 2; i <= sqrt; i++) { int firstNum = i; if (targetNumbers[i]) { for (int j = i * firstNum; j < targetNumbers.length; j = j + firstNum) { targetNumbers[j] = false; } } } for (int i = 2; i < targetNumbers.length; i++) { if (targetNumbers[i]) { cnt++; } } return cnt; } }