Showing run error in all test case
@anubhavb11 your code is giving run error cause n can be upto 10^5 as per constraints but you have taken array of size 10^4.
but still your code may give you TLE because using nested loops for this much constrains is not efficient.
try thinking efficient approach.