This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by their number. Each book has a distinct number.
He has lost many books, since many of his friends borrow his books and never bother to return them. He does not want to lose any more books and has decided to keep a record of all books that he lends to his friends. To make the task of borrowing a book a little difficult, he has given the following instructions to his friends: when they borrow a book, they must record in a register its position from the left among the books currently on the shelf.
Suppose there are $5$ books in the library and they are arranged as follows:
261421532614215326 \quad 1 \quad 42 \quad 15 \quad 3
If someone walks in and borrows the book $42$, then he will record $3$ in the register because this book is the third from the left on the shelf. Now the shelf looks like this:
26115326115326 \quad 1 \quad 15 \quad 3
If the next person borrow the book $3$, he writes down $4$ in the register since this is currently the fourth book from the left on the shelf, and so on.
Indraneel knows the initial arrangement of the books in his library at the time that he introduced the register system. After a while he examines his register and would like to know which books have been borrowed. Your task is to write a program to help Indraneel solve this problem.

-----Input:-----
The first line of the input contains a single integer $M$ indicating the number of books in Indraneel's library. The next line contains $M$ distinct positive integers describing the sequence in which the books are arranged on the library shelf. The third line of input contains a single integer $N$ indicating the number of entries in the register. This, in turn, is followed by $N$ lines (lines $4$ to $N+3$), each containing one positive integer. The integer on line $3+i$ indicates the position from left of the book ith book borrowed. (You may assume that the number on line $3+i$ is at most $M-i+1$.)

-----Output:-----
$N$ lines with one positive integer on each line. The number on line $i$ is the book borrowed by the ith borrower.

-----Constraints:-----
- $1 \leq M \leq 1000000$.
- $1 \leq N \leq 4000$.

-----Sample Input-----
5
26 1 42 15 3 
2
3
4

-----Sample Output-----
42
3

Difficulty: interview

Starter code:

Solutions:
def bookList():
    numBooks=int(input())
    bookNum=[int(x) for x in input().split()]
    takenBooks=int(input())
    for i in range(takenBooks):
        takenBookPos=(int(input()))
        a=bookNum[takenBookPos-1]
        print(a)
        bookNum.remove(a)

bookList()


########################################################
################# Template #############################
import sys
import math
def Int(): return int(input())
def Str(): return input()
def Ints(): return list(map(int,input().split(" ")))
def int_arr(): return list(map(int,input().strip().split(" ")))
def str_arr(): return list(map(str,input().split(" ")))
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
#########################################################
#vsInput()
no_of_books = Int()
books = int_arr()
no_aken = Int()
for i in range(no_aken):
    position =Int()
    print(books[position-1])
    books.pop(position-1)


def solve():
    pass
n = int(input())
arr = list(map(int,input().split()))
m = int(input())
for i in range(m):
    book_pos = int(input())
    print(arr.pop(book_pos-1))

n=int(input())
arr=list(map(int,input().split()))
k=int(input())
for _ in range(k):
    no=int(input())
    print(str(arr[no-1]))
    arr.remove(arr[no-1])


n=int(input())
arr=list(map(int,input().split()))
k=int(input())
for _ in range(k):
    no=int(input())
    print(str(arr[no-1]))
    arr.remove(arr[no-1])


try:
    M = int(input())
    BNA = list(map(int, input().split()))
    N = int(input())
    BN = []
    for i in range(N):
        BN.append(int(input()))
    l = []
    for i in BN:
        l.append(BNA[i-1])
        BNA.remove(BNA[i-1])
    print('\n'.join(map(str, l)))
except:
    pass


try:
    M = int(input())
    BNA = list(map(int, input().split()))
    N = int(input())
    BN = []
    for i in range(N):
        BN.append(int(input()))
    l = []
    for i in BN:
        l.append(BNA[i-1])
        BNA.remove(BNA[i-1])
    print('\n'.join(map(str, l)))
except:
    pass


n= int(input())
a=list(map(int,input().strip().split()))
t= int(input())
for i in range(t):
    j=int(input())
    print(a.pop(j-1))

t = int(input())
l = list(map(int,input().split()))
n = int(input())
for _ in range(n):
    t = int(input())
    print(l[t-1])
    del l[t-1]

try:
    m = int(input())
    l = list(map(int, input().split()))
    for _ in range(int(input())):
        n = int(input()) - 1
        print(l[n])
        del l[n]
except:
    pass

M = int(input())
arr = list(map(int,input().split()))
N = int(input())
ans = []
for i in range(N):
    a = int(input())
    ans.append(arr[a-1])
    arr.pop(a-1)
for i in ans:
    print(i)


M = int(input())
arr = list(map(int,input().split()))
ans = []
for i in range(int(input())):
    a = int(input())
    ans.append(arr[a-1])
    arr.pop(a-1)
for i in ans:
    print(i)


M = int(input())
arr = list(map(int,input().split()))
N = int(input())
ans = []
for i in range(N):
    a = int(input())
    ans.append(arr[a-1])
    arr.pop(a-1)
for i in ans:
    print(i)


try:
    t = int(input())
    k = list(map(int, input().split()))
    p = int(input())
    for _ in range(p):
        h = int(input())
        print(k[h - 1])
        k.remove(k[h - 1])

except:
    pass


n=int(input())
L=list(map(int,input().split()))
friends=int(input())
li=[]
for _ in range(friends):
    fB=L.pop(int(input())-1)
    li.append(fB)
for i in li:
    print(i)

n = int(input())
x = list(map(int,input().split( )))
t = int(input())
def function(x,y):
    p = x[y-1]
    x.remove(x[y-1])
    return p
for i in range(t):
    y = int(input())
    print(function(x,y))


n = int(input())
l = [int(i) for i in input().split()]
q = int(input())
while q != 0:
	a = int(input())
	x = l.pop(a-1)
	print(x)
	q = q - 1

n=int(input())
a=list(map(int,input().split()))
m=int(input())
l=[]
for i in range(m):
    x=int(input())
    l.append(a.pop(x-1))
for j in l:
    print(j)

m=int(input())
a=list(map(int,input().split()))
for i in range(int(input())):
    n=int(input())
    print(a[n-1])
    a.remove(a[n-1])


# // Problem : List of Books
# // Contest : CodeChef - IARCS OPC Judge Problems
# // URL : https://www.codechef.com/IARCSJUD/problems/BOOKLIST
# // Memory Limit : 256 MB
# // Time Limit : 2000 ms
# // Powered by CP Editor (https://github.com/cpeditor/cpeditor)

n = int(input())
a = list(map(int,input().split()))
q = int(input())
for i in range(q):
	k = int(input())
	print(a[k-1])
	a.pop(k-1)

n=int(input())
arr=[int(x) for x in input().split()]
m=int(input())
for _ in range(m) :
    q=int(input())
    val=arr[q-1]
    print(val)
    arr.remove(val)

#https://www.codechef.com/IARCSJUD/problems/BOOKLIST

try:
    num_books = int(input())

    books = [int(x) for x in input().split()]

    borrows = int(input())

    for i in range(borrows):
    
        curbook_index = int(input()) - 1
        curbook = books.pop(curbook_index)
    
        print(curbook)

except:
    pass

n = int(input())
arr = [int(x) for x in input().split()]
m = int(input())
ans = []
while m > 0:
    x = int(input())
    val = arr[x - 1]
    ans.append(val)
    arr.remove(val)
    m -= 1
for x in ans:
    print(x)