from collections import Counter


class Combination:
    def __init__(self, n):
        """

        :param n: 使用する最大のn (nCm)
        """
        self.n = n
        self.memo = [None for _ in range(n + 1)]
        self.memo[0] = [1]
        for i in range(1, n + 1):
            self._nCm_pascal(i)

    def _nCm_pascal(self, i):
        """
        パスカルの三角形のn階層目のリストを取得する
        :param i: 作成する階層
        :return:
        """
        if self.n < i:
            return

        pre_row = self.memo[i - 1]
        row = [1] * (i + 1)

        for j in range(1, i):
            row[j] = pre_row[j - 1] + pre_row[j]

        self.memo[i] = row

    def nCm(self, n, m):
        return self.memo[n][m]


N = [int(_) for _ in input().split()][0]
a = [int(_) for _ in input().split()]
s = [0] * (N + 1)

cnt = Counter()
comb = Combination(N)
for i in range(N):
    s[i + 1] = a[i] + s[i]
    cnt[s[i + 1]] += 1

ans = 0
for k, v in cnt.items():
    # print(k,v)
    if v <= 1: continue
    ans += comb.nCm(v, 2)
ans += cnt[0]
print(ans)
