if __name__ == '__main__':
    N = input()
    array = input().split()
    array = list(map(int, array))
    array_len = len(array)
    result = 0

    for start_num in range(array_len):
        sum = 0
        sum += array[start_num]
        for end_num in range(start_num + 1, array_len):
            sum += array[end_num]
            if sum == 0:
                result += 1

    print(result)
