using System;
using System.Collections.Generic;
using System.Linq;

class param {
  public long num = 0;
  public int count = 0;
  public param (long a) {
    num = a;
    count = 1;
  }
}

class Program {
  static void Main (string[] args) {
    long N = long.Parse (Console.ReadLine ());
    long[] a = new long[100000000];

    string[] input = Console.ReadLine ().Split (' ');
    for (int i = 0; i < N; i++) {
      a[i] = long.Parse (input[i]);
    }

    List<long> alist = new List<long> ();
    List<param> alist2 = new List<param> ();

    int count = 0;

    long[] b = new long[100000000];

    for (int i = 0; i < N - 1; i++) { //10^5回
      long value = a[i];
      if (b[i] > 0) continue;
      for (int j = i + 1; j < N; j++) { //10^5回
        if (i == 0 && j == N - 1) continue;
        value += a[j];
        if (value == 0) {
          count++;
          b[j + 1] = 1;
        }
      }
    }

    Console.WriteLine (count);

  }

}