from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    spam = [0] * (N + 1)
    for i, x in enumerate(A):
        spam[i + 1] = spam[i] + x
    count = 0
    for i, value in enumerate(spam):
        count += len([x for x in spam[i + 1:] if x == value])
    print(count)


if __name__ == '__main__':
    main()
