Petrol Pump Test cases not working

Some of the test cases are not working. what is thr problem with my code?
Here is my code-

Consider a case:
5
2 3 4
3 4 3

Expected O/p:
-1

Your O/p:
1

Crosscheck your code with this case

It’s working fine only. You have taken n to be 5 instead of 3.

Your code seems correct.
Try to submit it on leetcode and check https://leetcode.com/problems/gas-station/

It’s got accepted in leetcode.

Then there are some test case issues here.
It will be corrected soon