Array conceptual problem

https://ide.geeksforgeeks.org/1o6Ux0Crto.
can u see why my code is not giving correct answer.and how to optimize this.
problem is from geeks for geeks
https://practice.geeksforgeeks.org/problems/three-great-candidates/0

@Sumant123 Bro the code is correct, the same logic you asked me before. Just make the array type long, the range is of int but I think there is some problem going on with their platform.

Also I have discussed an optimized approach in the previous doubt of yours which is based on this approach only. Check that.

If any doubts lemme know!