Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Prisoners of Musabad

By TarifEzaz · Limits 2s, 512 MB

In the city of Musabad, criminals are punished heavily. Once an enemy is caught, he is kept in the jail forever. But the criminals of Musabad are clever, and they often break from the prison. Some of them even get caught one or more times after escaping from the prison. Each time a criminal enters the prison, his identity number is saved in some secret directory. Now, the warden is suspicious about the prison break and wants to find out those criminals who was arrested and put into prison at least twice during their lifetime.

Help Warden by writing the program for him.

Input

The first line of the input contains the number n (1 ≤ n ≤ 1000), the number of prisoner entry records in the secret directory. The next line contains n space separated integers ai (-1000 ≤ ai ≤ 1000 ), where each ai in a unique identifier for each of the criminals. After that there is an integer m (1 ≤ m ≤ 106), the number of queries that the warden would make. The next line contains m space separated integers bi (-1000 ≤ bi ≤ 1000), denoting the identifier of the prisoner. These are the ids that the warden wants to investigate.

Output

For each query, print "Yes" (w/o quotes), if the prisoner with the specified id has been arrested more than once. Otherwise, print "No" (w/o quotes).

Sample

InputOutput
9
1 2 3 4 5 1 2 3 4
5
5 4 3 2 1
No
Yes
Yes
Yes
Yes

Discussion

Statistics


83% Solution Ratio

BugXterminatorEarliest, Jun '16

NaimulFastest, 0.1s

BugXterminatorLightest, 262 kB

habijabiShortest, 222B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.