n = int(input())
nums = list(map(int,input().split()))

S = [0]

for i in range(n):
    S.append(S[i] + nums[i])

S.sort()
print(S)

ans = 0

for i in range(n):
    for j in range(i+1, n+1):
        if S[i] == S[j]:
            ans += 1
        elif S[i] > S[j]:
            break

print(ans)