Getting wrong answer

Please Help

find sum of array elements first

if sum==n

the check if n is odd or even and print answer accordingly

otherwise find nim sum and if its 0, brother wins and vice versa

What’s wrong in my code

why it is not working

you have to find nim sum with p and not p-1

only in case every pile value is 1 you have to find parity of n(odd or even, if odd john loses or vice versa)