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();
    // O(N^2-N)
    int count = 0;
    for (int i = 0; i < N-1; i++) {
      long sum = A[i];
      for (int j = i+1; j < N; j++) {
        if (A[j] == 0) {
          sum = 0;
          continue;
        }

        sum += A[j];
        if (sum == 0) {
          count++;
          if (j + 1 < N) {
            j++;
            sum = A[j];
          }
        }
      }
    }
    Console.WriteLine(count);
  }
}
