import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    S = [0]
    for i in range(N):
        A = int(input_raw[i])
        S.append(S[i] + A)
    sum_dic = {}
    for s in S:
        if s not in sum_dic:
            sum_dic[s] = 1
        else:
            sum_dic[s] += 1
    count = 0
    sum_dic[0] -= 1
    for su in sum_dic:
        count += sum_dic[su] * (sum_dic[su] - 1)/2
        if su == 0:
            count += sum_dic[su]


    print count

if __name__ == '__main__':
    main()