1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np

n=int(input())
a = np.array(input().strip().split(), int)
buc = np.array(0)

for i in range(n):
    for j in range(i+1, n+1):
        buc = np.append(buc, np.sum(np.array(a[i:j]))   )

buc = np.delete(buc, 0, 0)
bucSize = np.size(buc)

result = 0

for i1 in range(0, bucSize - 2):
    for i2 in range(i1 + 1, bucSize - 1):
        # print(f"i2: {buc[i1+1:bucSize]}")
        tmpArr = np.array(buc[i2 + 1 : bucSize])
        result += np.count_nonzero(tmpArr == -buc[i1] - buc[i2])

print(result)