using System;
using System.Linq;
public class Test
{
    public static void Main()=>Console.WriteLine("{1}",Console.ReadLine(),Console.ReadLine().Split().Select(s => long.Parse(s)).Aggregate(new long[] {0}.AsEnumerable(),(e,i)=>e.Concat(new long[] {i+e.Last()})).GroupBy(v=>v).Select(g=>g.LongCount()).Where(i=>i>1).Select(i=>i*(i-1)/2).Sum());
}