using System;
using System.Linq;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    // O(N^2) = O(10^10)
    int count = 0;
    for (int i = 0; i < N; i++) {
      int sum = A[i];
      for (int j = i+1; j < N; j++) {
        sum += A[j];
        if (sum == 0) {
          count++;
        }
      }
    }
    Console.WriteLine(count);
  }
}
