Simple input problem

if i give input like
2
3
-5

then why its showing error???
as when -5 is processed till then cumulative sum becomes 0. after that it checks for next input but as there is no input so it gives “no such element” exception.
so how to check whether there is element present on console or not.

sum is zero, yet your code is processed. if sum is negative then terminate your code . so take one more input ,that make negative sum

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.