import numpy as np


def solve(n):
    a = np.array(list(map(int, input().split())))
    accm = np.cumsum(a)
    arr_count = np.zeros(n+1, dtype="uint64")

    for ai in accm:
        arr_count[ai] += 1

    arr_larger_1 = arr_count[arr_count > 1]
    ans = arr_count[0]

    for p in arr_larger_1:
        ans += sum(list(range(1, p)))

    return int(ans)


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