using System;

namespace ZeroSumRanges {
    class Program {
        static void Main(string[] args) {

            int N = int.Parse(Console.ReadLine());
            long[] a = new long[N];
            String[] split = Console.ReadLine().Split(' ');
            for(int i = 0; i < N; ++i) {
                a[i] = int.Parse(split[i]);
            }

            long ans = 0;
        
            for(int length = 1; length <= N; ++length) {
                for(int start = 0; start <= N - length; ++start) {
                    long sum = 0;
                    for(int i = 0; i < length; ++i) {
                        sum += a[start + i];
                    }
                    if (sum == 0) ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}
