Matched Brackets ZC012001

I am getting 3 test cases wrong, I didn’t get where I am wrong.

Here is my code

```
n = int(input())
a = list(map(int, input().split()))
b = []
c = 0
d = []
e = []
g = []
flmb = 0
for i in range(len(a)):
if(a[i] == 1):
b.append(a[i])
c += 1
else:
if(len(b) == 0):
break
else:
d.append(len(b))
b.pop()
c -= 1
g.append(i)
if(len(b) == 0):
e.append(i+1)
#print(b)
#print(d)
#print(e)
#print(g)
nd = max(d)
for i in range(len(d)):
if(d[i] == nd):
j = i
break
fnd = g[j]
lmb = 0
if(len(e) == 1):
lmb = e[0]
flmb = 1
else:
for i in range(len(e)-1):
if(lmb < abs(e[i+1] - e[i])):
lmb = abs(e[i+1] - e[i])
flmb = e[i] + 1
print(nd, fnd, lmb, flmb)
```