Run time error in All test cases

https://online.codingblocks.com/app/player/39329/content/89496/5290/code-challenge
run time rroe in all cases but passes sample ip in ide.
also please check logic for this code

hello @rastogi.g1998

image
value of n can be upto 1000 00 so increase ur array size.