import sys
sys.setrecursionlimit(10000)

def search(i, j, a):
    for k in range(i + 1, j, 1):
        if(sum(a[i:k]) == 0):
            return k + 1
    return 0

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

ans = 0
flag = []

for i in range(len(a)):
    m = 0
    if(i in flag):
        continue
    for j in range(i + 1, len(a) + 1, 1):
        if(sum(a[i:j]) == 0):
            m += 1
            j += 1
            while(True):
                k = search(j - 1, len(a) + 1, a)
                if(k == 0 or k == len(a) + 1):
                    break
                flag.append(j)
                m += 1
                j = k
            ans += m * (m + 1) / 2
            break

print(int(ans))