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;

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

    // alist.Add (a[0]);
    // alist.Add (0);

    // for (int i = 1; i < N; i++) { //10^5回
    //   int num = alist.Count;
    //   for (int j = 0; j < num; j++) { //?
    //     if (alist[j] != 0) {
    //       if (alist[j] + a[i] == 0) count++;
    //     }
    //     alist[j] += a[i];
    //   }
    //   alist.Add (0);
    // }

    // alist2.Add (new param (a[0]));
    // alist2.Add (new param (0));
    // for (int i = 1; i < N; i++) { //10^5回
    //   int num = alist2.Count;
    //   for (int j = 0; j < num; j++) { //?
    //     if (alist2[j].num != 0) {
    //       if (alist[j] + a[i] == 0) count++;
    //     }else{

    //     }
    //     alist[j] += a[i];
    //   }
    //   alist.Add (0);
    // }

    Console.WriteLine (count);

  }

}