```
class Solution(object):
def canCompleteCircuit(self, gas, cost):
"""
:type gas: List[int]
:type cost: List[int]
:rtype: int
"""
sth=len(gas)
s=[0]*sth
for i in range(len(gas)):
s[i]=gas[i]-cost[i]
left=0
ans=s[0]
for i in range(sth):
if ans<0:
ans=0
left=i
ans+=s[i]
return left if sum(s)>=0 else -1
```