structure A  = Array
structure I  = Int
structure LI = LargeInt
structure SC = StringCvt
structure T  = TextIO

fun nextInt () = valOf (T.scanStream (I.scan SC.DEC) T.stdIn)

fun nextLInt () = valOf (T.scanStream (LI.scan SC.DEC) T.stdIn)

fun solve (ary : LI.int array) =
    let
      val n   = A.length ary
      val i   = ref 0
      val j   = ref 0
      val sum = ref 0
      val cnt = ref 0
    in
      while !i < n do (
        j := !i;
        sum := 0;
        while !j < n do (
          sum := !sum + A.sub (ary, !j);
          if !sum = 0 then cnt := !cnt + 1 else ();
          j := !j + 1
        );
        i := !i + 1
      );
      !cnt
    end

val () =
    let
      val n   = nextInt ()
      val ary = A.tabulate (n, fn _ => nextLInt ())
    in
      print (I.toString (solve ary) ^ "\n")
    end
