Pivot sorted array problem

#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

@karthik1989photos,
Please provide CodingBlocks IDE link of your code.


i am unable to sharetheough CB ide…so i am sharing through other ide

please reply for my doubt

@karthik1989photos,
Reduce the size of array, its too big, also why are you facing issues with Coding Blocks IDE?
Just go to this link https://ide.codingblocks.com. Paste you code here, with input in input section, Hit save and share the link, simple.

even i decreased the size it is showing run time error

@karthik1989photos,
Check mid<e before accessing a[mid+1], same for a[mid-1].

i am unable to solve this…plz give me the solution

@karthik1989photos,
Let’s not jump onto codes, me giving you the code won’t help you solve the problem. You should try to debug your code. It may seem difficult at first, but it will be worth spending time.