Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 0
numbers = [ca.count(j) for j in list(set(ca)) if ca.count(j) > 1]
count += ca.count(0)
count += sum([int(i * (i-1) /2) for i in numbers])

print(count)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 0
for i in list(set(ca)):
    if i == 0:
        count += sum([1 if j == 0 else 0 for j in ca])
    number = sum([1 if j == i else 0 for j in ca])
    count += int(number * (number-1) /2)

print(count)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Buggy python submission (verdict: Time Limit Exceeded):
import scipy.misc as scm
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 0
for i in list(set(ca)):
    if i == 0:
        count += sum([1 if j == 0 else 0 for j in ca])
    count += scm.comb(
        sum([1 if j == i else 0 for j in ca])
    ,2,1)


print(count)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
ret_arr = [0]*N

def ca(n):
    if n == 1:
        array = np.zeros(N - n + 1)
        array[0] = sum([A[i] for i in range(n)])
        for i in range(1, N - n + 1):
            array[i] = array[i - 1] + A[n + i - 1] - A[i - 1]
        ret_arr[0] = array
    else:
        array = A[n-1:N] + np.array(ret_arr[n-2][0:N-n+1])
        ret_arr[n-1] = array
    return array


count = 0
for j in range(1, N+1):
    count += sum([1 if k == 0 else 0 for k in ca(j)])

print(count)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]


def ca(n):
    array = [0]*(N-n+1)
    array[0] = sum([A[i] for i in range(n)])
    for i in range(1,N - n + 1):
        array[i] = array[i - 1] + A[n + i - 1] - A[i-1]
    return array


count = 0
for j in range(1, N+1):
    count += sum([1 if k == 0 else 0 for k in ca(j)])

print(count)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
leng = len(A)


def zero(n,a,l):
    count = 0
    for i in range(l - n + 1):
        part = a[i:i +n]
        if sum(part) == 0:
            count = count + 1
    return count


count_1 = 0
for j in range(1, leng+1):
    count_1 = count_1 + zero(j,A,leng)

print(count_1)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))