using System;
using System.Collections.Generic;

class ZeroSumRanges{
    static void Main(string[] args){
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ');
        var alist = new List<int>(n);
        foreach(var a2 in a){
            alist.Add(int.Parse(a2));
        }
        
        var count = 0;
        for(int i=2; i<n; i++){
            for(int j=0; j<n; j++){
                var copy = new int[i];
                if(j+i>n){
                    continue;
                }
                alist.CopyTo(j, copy, 0, i);
                var sum = 0;
                foreach (var item in copy)
                {  
                    sum = sum + item; 
                }
                if(sum == 0){
                    count = count + 1;
                }
            }
        }
        Console.WriteLine(count);
    }
}