//递归二分
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int a[10000+10];
int binary_search(int key,int left,int right)
{
int mid=left+right>>1;
if(left>right)
return -1;
if(a[mid]==key)
return mid;
if(a[mid]>key)
return binary_search(key,left,mid-1);
else
return binary_search(key,mid+1,right);
}
int main()
{
std::ios::sync_with_stdio(false);
int n,m;
while(cin>>n)
{
for(int i=1; i<=n; i++)
{
cin>>a[i];
}
cin>>m;
printf("%d\n",binary_search(m,1,n));
}
return 0;
}
//循环二分
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int a[10000+10];
int binary_search(int key,int right)
{
int left=1,mid;
while(left<=right)
{
mid=left+right>>1;
if(a[mid]==key)
return mid;
if(a[mid]>key)
right=mid-1;
else
left=mid+1;
}
return -1;
}
int main()
{
std::ios::sync_with_stdio(false);
int n,m;
while(cin>>n)
{
for(int i=1; i<=n; i++)
{
cin>>a[i];
}
cin>>m;
printf("%d\n",binary_search(m,n));
}
return 0;
}