using System;
using System.Linq;

namespace AtCoderBeginnerContest095
{
    class ABC095C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select( m => int.Parse(m)).ToArray();
            int[] d = new int[N];
            for (int j = 0; j < N; j++)
            {
                int tmp = 0;
                for (int i = j; i < N; i++)
                {
                    tmp += a[i];
                    if (tmp == 0) d[i]++;
                }
            }
            Console.WriteLine(d.Sum());
        }
    }
}
