```
c = 0 #count
for i in range(len(A)):
if i != len(A) - 1:
temp = A[:i] + A[i+1:]
else:
temp = A[:i]
even = [temp[i] for i in range(0, len(temp), 2)]
odd = [temp[i] for i in range(1, len(temp), 2)]
if sum(even) == sum(odd):
c+= 1
return c
```

Could someone tell how do I optimise this in O(n), I am getting TLE. TIA