# require "template" lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end n = read_line.to_i64 a = read_line.split.map(&.to_i).chunk &.itself k = 0i64 a.each do |i| if i[0] > 0 p = i[1].size.to_i64 k += p*(p + 1)//2 end end puts n*(n + 1)//2 - k