class Solution(object):
def captureForts(self, forts):
"""
:type forts: List[int]
:rtype: int
"""
ans, pre = 0, -1
for i, fort in enumerate(forts):
if fort == -1 or fort == 1:
if pre >= 0 and fort != forts[pre]:
ans = max(ans, i - pre - 1)
pre = i
return ans