Logic seems correct but getting error

prob : https://hack.codingblocks.com/app/contests/1975/424/problem

sol: https://ide.codingblocks.com/s/388540

getting segmentation fault

Hello @raghav007 please wait.

Hello @raghav007 it is giving segmentation fault because you have to take input only the single input. i.e only number n but you are taking input for array elements array as well.
your logic is wrong.
you are taking unnecessarily inputs this is the reason it is resulting into segmentation fault.
because there is no input being provided but you are seeking input in your code.
you have to think something else.

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.