import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); TreeMap sums = new TreeMap<>(); for(int i = 0 ; i < n ; i++){ int num = sc.nextInt(); int cnt = constructPrimeNumbers(num , sums); System.out.println(cnt); sums.put(num , cnt); } } private static int constructPrimeNumbers(int maxNumber , TreeMap sums) { int cnt = 0; int first = 2; if(sums.lowerEntry(maxNumber) != null){ Map.Entry entry = sums.lowerEntry(maxNumber); cnt = entry.getValue(); first = entry.getKey(); } 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 = (int)Math.sqrt(first) ; 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 = first; i < targetNumbers.length; i++) { if (targetNumbers[i]) { cnt++; } } return cnt; } }