#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#define MAX 10001
using namespace std;
int a[MAX],key;
int search(int bot,int top)
{
int mid=(bot+top)/2;
if(bot<=top)
{
if(key>a[mid])
{
bot=mid+1;
search(bot,top);
}
else if(key<a[mid])
{
top=mid-1;
search(bot,top);
}
else
{
cout<<mid<<endl;
return 0;
}
}
else
{
printf("-1\n");
return 0;
}
}
int main()
{
freopen("half.in","r",stdin);
freopen("half.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;++i)
cin>>a[i];
cin>>key;
search(1,n);
return 0;
}
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#define MAX 10001
using namespace std;
int a[MAX],key;
int search(int bot,int top)
{
int mid=(bot+top)/2;
if(bot<=top)
{
if(key>a[mid])
{
bot=mid+1;
search(bot,top);
}
else if(key<a[mid])
{
top=mid-1;
search(bot,top);
}
else
{
cout<<mid<<endl;
return 0;
}
}
else
{
printf("-1\n");
return 0;
}
}
int main()
{
freopen("half.in","r",stdin);
freopen("half.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;++i)
cin>>a[i];
cin>>key;
search(1,n);
return 0;
}