ALICESIE - Alice Sieve

no tags 

Alice has recently learned to use the Sieve of Eratosthenes, an ancient algorithm for finding all prime numbers up to any given limit. As expected, she was really impressed by it's simplicity and elegancy.

Now, she has decided to design her own sieve method: The Sieve of Alice, formally defined by the following procedure, which determines the Sieve of Alice up to a given limit N.

  1. Create a list of consecutive integers from N to 2 (N, N-1, N-2, ..., 3, 2). All of those N-1numbers are initially unmarked.
  2. Initially, let P equal N, and leave this number unmarked.
  3. Mark all the proper divisors of P (i.e. P remains unmarked).
  4. Find the largest unmarked number from 2 to P – 1, and now let P equal this number.
  5. If there were no more unmarked numbers in the list, stop. Otherwise, repeat from step 3.

Unfortunately, Alice has not found an useful application for it's Sieve. But she still wants to know, for a given limit N, how many integers will remain unmarked.

Input

The first line contains an integer T, the number of test cases (1 ≤ T ≤ 10^4) . Each of the next T lines contains an integer N (2 ≤ N ≤ 10^6).

Output

Output T lines, one for each test case, containing the required answer.

Example

Input:
3
2
3
5

Output:
1
2
3

hide comments
emily50: 2023-09-10 12:57:58

Can you explain this problem?

eagleshadow: 2019-02-25 17:04:45

Try FINDPRM after this!!!

masterchef2209: 2018-10-14 14:52:01

stupid problem -_- just observe the pattern

piyushgupta222: 2018-08-22 15:36:37

Too easy.

deepak097: 2018-08-12 20:41:43

Got surprised :)

spmalviya1998: 2018-08-12 09:08:09

Must be in tutorial :)

rv111: 2018-02-16 08:14:48

took this question in wrong way and successfully wasted my couple of hours...,

sanyam19: 2018-01-02 07:45:57

easy peasy... :)

mpride44: 2017-12-28 17:24:42

hahaha....never expect this type of ques on spoj...

aronzx: 2017-08-28 07:10:38

You need to observe a pattern to solve this. My 100 problem :D


Added by:Paulo Costa
Date:2012-02-06
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:UNI