/*#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include<stdio.h>
int main()
{
int a[101];
int k[101];
int rank[101], r;
int i,j,n,temp,min,d,f;
scanf("%d", &n);
for(i=1; i<=n; i++)
{
scanf("%d %d", &a[i], &k[i]);
rank[i] = i;
}
for(i=1; i<=n ; i++)
{
min=i;
{
for(j=i; j<=n; j++)
{
if(a[min]<a[j])
{
min=j;
}
}
temp=a[min];
a[min]=a[i];
a[i]=temp;
r = rank[min];
rank[min] = rank[i];
rank[i] = r;
}
if(a[i]==a[i+1])
{
if(k[i]<k[i+1])
{
d=k[i];
k[i]=k[i+1];
k[i+1]=d;
r=rank[i];
rank[i]=rank[i+1];
rank[i+1]=r;
}
else if(k[i]=k[i+1])
{
}
}
}
for(i=1; i<=n; i++)
{
printf("%d %d %d\n ",rank[i],a[i], k[i]);
}
return 0;
}
*//*
#include<stdio.h>
int main()
{
int arr[1000] = {0};
int min, max, mid;
int i, j, n, k;
scanf("%d", &n);
for(i=0; i<n; i++) {
scanf("%d", &arr[i]);
}
min = 0;
max = n-1;
mid = (min+max)/2;
scanf("%d", &k);
for(;;) {
if(min == max && k != arr[mid]) {
printf("-1 ");
break;
}
if(k == arr[mid]) {
printf("%d", mid);
break;
}
else if(k > arr[mid]) {
min = mid+1;
mid = (min+max)/2;
}
else if(k < arr[mid]) {
max = mid;
mid = (min+max)/2;
}
}
}
*//*
#include<stdio.h>
int main()
{
int arr[1000005]= {0};
int b[1000005]= {0};
int min,max,mid,i,j,n,k,m;
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d", &arr[i]);
}
scanf("%d", &m);
for(i=0; i<m; i++)
{
scanf("%d", &b[i]);
}
for(i=0; i<m; i++)
{
min=0;
max=n-1;
mid=(min+max)/2;
{
for(;;)
{
if(b[i]==arr[mid])
{
printf("%d ", mid+1);
break;
}
else if(min==max&&b[i]!=arr[mid])
{
printf("-1 ");
break;
}
else if(b[i]>arr[mid])
{
min=mid;
mid=(min+max)/2+1;
}
else if(b[i]<arr[mid])
{
max=mid-1;
mid=(min+max)/2;
}
}
}
}
}
*/