#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
int n,m,i,j,mid,x,k;
int a[100005];
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&m);
for (k=0;k<m;k++)
{
scanf("%d",&x);
for (i=-1,j=n;i+1<j;)
{
mid=(i+j)/2;
if (a[mid]>x)
j=mid;
else
i=mid;
}
if (abs(x-a[i])<=abs(a[j]-x))
printf("%d\n",a[i]);
else
printf("%d\n",a[j]);
}
return 0;
}
oj只得了5分