student = []
tim = []
people = int(input(" "))
high = int(input(" "))

for i in range(0,people):
    student.append(int(input(" ")))

for i in range(people):
    for j in range(0, people-i-1):
        if student[j] > student[j+1] :
            student[j], student[j+1] = student[j+1], student[j]

for i in range(0,high):
    
    tim.append(int(input(" ")))
    
for i in range(0,high):
    print(student[tim[i]-1])