using System;
using System.Linq;
using System.Collections;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //string[] s = Console.ReadLine().Split(' ');
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        long[] asum = new long[n];
        asum[0] = a[0];
        for (int i = 1; i < n; i++)
            asum[i] = asum[i - 1] + a[i];
        int ans = 0;
        for (int i = 0; i < n - 1; i++)
            if (a[i] + a[i + 1] == 0)
                ans++;
        Array.Sort(asum);
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            if (i == n - 1 || asum[i] != asum[i + 1])
            {
                count++;
                ans += count * (count - 1) / 2;
                count = 0;
            }
            else
                count++;
        }
        Console.WriteLine(ans);
    }
}