using System;
using System.Linq;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    long[] A = new[]{ 0L }.Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();
    for (int i = 2; i < N+1; i++) {
      A[i] = A[i-1] + A[i];
    }
    Array.Sort(A);
    int count = A.Distinct().Select(x => A.Count(y => x == y)).Select(x => x * (x-1) / 2).Sum();
    Console.WriteLine(count);
  }
}
