#include
using namespace std;
using ll= long long ;
int main() {
ll n; cin>>n;
ll a[10000000];
for(int i=0;i<n;i++){
cin>>a[i];
}
ll s=0;ll e=n-1;
ll mid;
while(s<=e){
mid=(s+e)/2;
if(a[mid]>a[mid+1]&&mid<e){
cout<<mid;break;
}
if(a[mid]<a[mid-1]&&mid>s){
cout<<mid-1;break;
}
if(a[s]>=a[mid]){ //left part will be unsorted and pivot will lie in left part
e=mid-1;
}
if(a[e]<=a[mid]){ //right part will be unosorted and pivot will be in right part
s=mid+1;
}
}
return 0;
}
why i am getting error on compiling i.e segmentation fault error