using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        long[] a = ReadLongArray();

        long[] b = new long[n+1];
        var d = new Dictionary<long, int>();
        d.Add(0, 1);
        for (int i = 1; i <= n; i++)
        {
            long x = b[i] = b[i-1] + a[i-1];
            if (!d.ContainsKey(x)) d.Add(x, 0);
            d[x]++;
        }

        long ans = 0;
        foreach (int k in d.Keys)
        {
            int i = d[k];
            ans += (long) i * (i - 1) / 2;
        }

        WriteLine(ans);
    }
}