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 count = 0;
        for(int i=2; i<n; i++){
            for(int j=0; j<n; j++){
                if(j+i>n){
                    continue;
                }
                var sublist = new string[i];
                Array.Copy(a, j, sublist, 0, i);
                var sum = 0;
                foreach (var item in sublist)
                {  
                    sum = sum + int.Parse(item); 
                }
                if(sum == 0){
                    count = count + 1;
                }
            }
        }
        Console.WriteLine(count);
    }
}