Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
Z = [[0 for m in range(N+1)] for n in range(N) ]
result = 0

for k in range(N):
        Z[0][k] = A[k]
        if Z[0][k] == 0:
                result = result+1

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        Z[i][j] = Z[i-1][j-1]+Z[0][j]
        if Z[i][j]  ==0:
                result = result+1
print(result)

Fixed submission:
import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

print(int(result))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
Z = [[0 for m in range(N+1)] for n in range(N) ]
result = 0

for k in range(N):
        Z[0][k] = A[k]
        if A[k] == 0:
                result = result+1

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        tmp = Z[i-1][j-1]+Z[0][j]
        if tmp ==0:
                result = result+1
        Z[i][j] = tmp
print(result)

Fixed submission:
import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

print(int(result))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
#Z = np.zeros((N+1,N))
Z = [[0]*int(N+1) for i in range(N) ]
#Z[0,:] = np.array(A)
result = 0

for k in range(N):
        Z[0][k] = A[k]
        if A[k] == 0:
                result = result+1

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        tmp = Z[i-1][j-1]+Z[0][j]
        if tmp ==0:
                result = result+1
        Z[i][j] = tmp
print(result)

Fixed submission:
import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

print(int(result))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
Z = np.zeros((N+1,N))
Z[0,:] = np.array(A)
result = 0

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        tmp = Z[i-1,j-1]+Z[0,j]
        if tmp ==0:
                result = result+1
        Z[i,j] = tmp
print(result)

Fixed submission:
import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

print(int(result))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
Z = np.zeros((N+1,N))
Z[0,:] = np.array(A)
result = 0

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        tmp = Z[i-1,j-1]+Z[0,j]
        if tmp ==0:
                result = result+1
        Z[i,j] = tmp
print(result)

Fixed submission:
import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

print(int(result))