import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  auto sum = new long[](n+1);
  foreach (i; 1..n+1) {
    sum[i] = sum[i-1] + a[i-1];
  }

  int cnt;
  foreach (i; 0..n+1) {
    foreach (j; i+1..n+1) {
      if (sum[j] - sum[i] == 0) {
        //writeln(i, " ", j);
        cnt++;
      }
    }
  }
  cnt.writeln;
}
