import numpy as np

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


def get_sum0_subsets(x):
    x = np.array(x)
    x = np.insert(x, 0, 0)
    tmp = count_num(x.cumsum())
    tmp = tmp[tmp > 1]
    return np.sum([np.sum(np.arange(x)) for x in tmp])

def count_num(x):
    tmp_dict = dict()
    for i in x:
        if i in tmp_dict:
            tmp_dict[i] += 1
        else:
            tmp_dict[i] = 1
    
    return np.array(list(tmp_dict.values()))

print(get_sum0_subsets(a))