n = input() v = list(map(int, raw_input().split())) v.append(0) sol, cnt = 0, 0 for i in range(0, len(v)): if v[i] == 1: cnt += 1 else: sol += cnt // 2 cnt = 0 print sol