import numpy as np


def solve(n):
    a = np.array(list(map(int, input().split())))
    arr_accm = np.cumsum(a)
    arr_index = []
    arr_count = []

    for ai in arr_accm:
        if ai in arr_index:
            match_index = arr_index.index(ai)
            match_count = arr_count[match_index]
            arr_count[match_index] = match_count+1
        else:
            arr_index.append(ai)
            arr_count.append(1)

        ans = arr_count[arr_index.index(0)] if 0 in arr_index else 0

    arr_lt_1 = np.array(arr_count)

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

    return ans


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