// https://www.geeksforgeeks.org/search-almost-sorted-array/
#include<iostream>
using namespace std;
int func (int a[], int l, int r, int x){
if (l <= r){
int m=(l+r)/2;
if (a[m] == x)
return m;
if (a[m-1] == x)
return m-1;
if (a[m+1] == x)
return m+1;
if (a[m] < x)
return func(a,m+2,r,x);
if (a[m] > x)
return func(a,l,m-2,x);
}
return -1;
}
int main(){
int n,x;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cout<< "Enter the search element:";
cin>>x;
int j=func(a,0,n-1,x);
if (j != -1)
cout<< "Element is present at index: "<<j;
else
cout<< "Element is not present.";
}