Merge sort recursion

#include
using namespace std;
#define ll long long
void merge(ll int a[],ll int s,ll int e){
ll int mid=(s+e)/2;
ll int i=s;
ll int j=mid+1;
ll int k=s;
ll int temp[1000];
while(i<=mid&&j<=e){
if(a[i]<a[j]){
temp[k++]=a[i++];
}
else{
temp[k++]=a[j++];
}
}
while(i<=mid){
temp[k++]=a[i++];
}
while(j<=e){
temp[k++]=a[j++];
}
for(int i=s;i<=e;i++){
a[i]=temp[i];
}
}
void mergesort(ll int a[],ll int s,ll int e){
if(s>=e){
return ;
}
ll int mid=(s+e)/2;
mergesort(a,s,mid);
mergesort(a,mid+1,e);
merge(a,s,e);

}
int main(){
ll int n;
cin>>n;
ll int *a=new ll int[n];
for( int i=0;i<n;i++){
cin>>a[i];
}
mergesort(a,0,n-1);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
why it is showing run error?

please save your code at https://ide.codingblocks.com and then share the link

size of your temp array is very less. Since n could be 2100000, so e can be 2100000. So increase the size of your temp array to 200000.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.