import numpy as np


def solve(n):
    a = np.array(list(map(int, input().split())))
    count = 0

    for i in range(n):
        sum_from_i = np.cumsum(a[i:n])
        count += np.count_nonzero(sum_from_i == 0)
    return count


if __name__ == '__main__':
    n = int(input())
    print(solve(n))
