Run error is coming

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int x[40010],y[40010];
for(int i=0;i<n;i++){
cin>>x[i]>>y[i];
}
sort(x,x+n);
sort(y,y+n);
int dx=x[0]-1;
int dy=y[0]-1;
for(int i=1;i<n;i++){
dx=max(dx,x[i]-x[i-1]-1);
dy=max(dy,y[i]-y[i-1]-1);
}
cout<<dx*dy<<endl;
return 0;
}

@mansi25 range of N is upto 10^5 but you have taken arrays of size 40010, thats why you are getting a run error.