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