    using System;
    using System.Collections.Generic;
    using static System.Console;
    using System.Linq;


class Program
{
    static void Main(string[] Args) {
        ReadLine();
        var A_ = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        var A = new List<int>();
        A.Add(0);
        int Sum = 0;
        foreach(int e in A_) {
            Sum += e;
            A.Add(Sum);
        }

        var duplicationList = A
            .GroupBy(i => i)
            .Where(g => g.Count() > 1)
            .Select(g => new { number = g.Key, duplicationCount = g.Count() - 1 })
            .ToList();

        int Result = 0;
        foreach (var e in duplicationList) {
            Result += (e.duplicationCount >= 1) ? e.duplicationCount : 0;
        }

        WriteLine(Result);

        ReadLine();
    }
}