using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<long, long>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var w = 0L; d[w] = 1;
        for (int i = 0; i < n; i++)
        {
            w = a[i] + w;
            if (d.ContainsKey(w)) d[w]++;
            else d[w] = 1;
        }
        Console.WriteLine(getAns(d));
    }
    public static long getAns(Dictionary<long, long> d)
    {
        var ret = 0L;
        foreach (var x in d)
            if (x.Value >= 2 && x.Value % 2 == 0) ret += (x.Value / 2) * (x.Value - 1);
            else if (x.Value >= 2 && x.Value % 2 != 0) ret += (x.Value - 1 / 2) * x.Value;
        return ret;
    }
}
