// https://www.geeksforgeeks.org/find-position-element-sorted-array-infinite-numbers/
#include <iostream>
using namespace std;
int binary (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]>x)
return binary(a,l,m-1,x);
return binary(a,m+1,r,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 l=0,r=1,k=a[0];
while (k<x){
l = r;
r = 2*r;
k = a[r];
}
int j=binary(a,l,r,x);
cout<< "Index at "<<j;
}