I am getting run error for on of the test case for the following code

Check the constraints given in the question
Constraints
1<=N<=10^6 0<=Ai<=10^6

In line number 8 and 9, you have limited the size of the array to 10. So it will give run error for large inputs. Increase its size according to the constraints and then check.

I have made the necessary changes but then also I am getting error while compilation.

What are you performing from line 26 to line 38. I don’t think so it is required. And error is most probably because of some line there. Dry run and check that.

A simple approach is like this:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.