Regarding Histogram area problem


This is my ode .
In this I am getting run error while I am submitting the code

Try to take the array as long long int ar[1000001] and also, long long int N;