n = int(input()) l = [0]+list(map(int, input().split()))+[10**9+1] c = 0 for i in range(1,n+1): if l[i-1]