#include <cstdio>
#include <vector>
using namespace std;
#define f(a) for(int i=1;i<=a;i++)
inline int read(){
int s=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
if(ch=='-') f=-1;
ch=getchar();
while(ch>='0'&&ch<='9')
s=s*10+ch-'0';
ch=getchar();
return s*f;
}
int n,m;
vector<int> v(1);
int main(){
n=read(); m=read();
f(n) v.push_back(read());
f(m) printf("%d\n",v[read()]);
return 0;
}