Why i am getting run time error?

plz use the size of array as,
long long int N=1000000;
long long int p[N];
and then try to submit your code,

I have edited your code a little bit, I have used array for storing instead of vector,