#include<vector>
using namespace std;
struct ListNode
{
int num;
ListNode *next;
};
int main()
{
int i,n,m,x,count=0;
ListNode *head;
head=new ListNode;
head->next=NULL;
ListNode *p,*q;
q=head;
cin>>n>>m;
for(int i=0; i<n; i++)
{
cin>>x;
p=new ListNode;
p->num=x;
q->next=p;
q=p;
}
q->next=NULL;
for(int i=0; i<m; i++)
{
count=0;
cin>>x;
p=head;
while(p)
{
p=p->next;
count++;
if(count==x)
{
cout<<p->num<<endl;
break;
}
}
}
return 0;
}