I need some help with the BOOKLIST problem

I am new to Competitive programming, and also to programming as a whole. Link to the problem I am stuck on : https://www.codechef.com/IARCSJUD/problems/BOOKLIST

I wrote the following code as a solution in python:

M = input()
books = list(input().split(" "))
N = int(input())
brr_books = []
for i in range(N):
    x = int(input())
    brr_books.append(books[x - 1])
for j in brr_books:

I am getting the correct answer for the test case, but the judge is evaluating my solution as wrong. I would highly appreciate if someone can point out the flaw in my code. Thank you in advance :slight_smile: