import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = np.zeros(n)
    for i,ai in enumerate(a):
        sa[i] = sa[i-1]+ai
    ans = np.count_nonzero(sa == 0)
    for i,ai in enumerate(a):
        sa = sa[1::]-ai
        ans += np.count_nonzero(sa == 0)
    print(ans)

    return

if __name__ == '__main__':
    main()
