Kindly help in finding where i am going wrong

the code link:

The second line provides you W space separated integers while you taking N number of inputs from the second line (Line 56)
Also in this question there is no need to use integer N anywhere in the solution because it has no relevance.
Read the question again carefully and then give it a try.

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.