# coding: utf-8

N = int(raw_input())
A = map(int, raw_input().split())

ans = 0; r = 0; l = 0;flag = True

while (r < N):
    l = r
    t = r+1
    flag = True
    while (l < N):
        if (sum(A[r:l+1]) == 0):
            ans += 1
            if flag:
                t = l
                flag = False
        l += 1
    r = t

print ans
