```
class Solution:
# @param gas, a list of integers
# @param cost, a list of integers
# @return an integer
def canCompleteCircuit(self, gas, cost):
if sum(gas) < sum(cost):
return -1
n = len(gas)
res = 0
s = 0
for i in range(n):
s += gas[i] - cost[i]
if s < 0:
s = 0
res = (i + 1) % n
return res
```