There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is on and $a_i = 0$ otherwise.

Vova thinks that people in the $i$-th flats are disturbed and cannot sleep if and only if $1 < i < n$ and $a_{i - 1} = a_{i + 1} = 1$ and $a_i = 0$.

Vova is concerned by the following question: what is the minimum number $k$ such that if people from exactly $k$ pairwise distinct flats will turn off the lights then nobody will be disturbed? Your task is to find this number $k$.


-----Input-----

The first line of the input contains one integer $n$ ($3 \le n \le 100$) — the number of flats in the house.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($a_i \in \{0, 1\}$), where $a_i$ is the state of light in the $i$-th flat.


-----Output-----

Print only one integer — the minimum number $k$ such that if people from exactly $k$ pairwise distinct flats will turn off the light then nobody will be disturbed.


-----Examples-----
Input
10
1 1 0 1 1 0 1 0 1 0

Output
2

Input
5
1 1 0 0 0

Output
0

Input
4
1 1 1 1

Output
0



-----Note-----

In the first example people from flats $2$ and $7$ or $4$ and $7$ can turn off the light and nobody will be disturbed. It can be shown that there is no better answer in this example.

There are no disturbed people in second and third examples.

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		c += 1
print(c)


k = int(input())
l = list(map(int, input().split()))
on = l.count(1)
if on == k:
	print(0)
	exit()
co = 0
for i in range(1, k - 1):
	if l[i] == 0:
		try:
			if l[i + 1] == 1 and l[i - 1] == 1:
				co += 1
				l[i + 1] = 0
		except:
			onnn = 98
print(co)


n = int(input())
s = str(input())
s = s.replace(' ', '')
x = s.count('101')
print(x)


n = int(input())
a = list(map(int, input().split()))
result = 0
for i in range(n):
	if i < n - 2:
		if a[i] == 1 and a[i + 2] == 1:
			for j in range(i + 2, n, 2):
				if a[j - 1] == 1 or a[j] == 0:
					result += ((j - i - 1) // 2 + 1) // 2
					break
				elif j >= n - 2:
					result += ((j - i + 1) // 2 + 1) // 2
					a[j] = 0
					break
				a[j] = 0
print(result)


n = int(input())
a = [int(i) for i in input().split()]
s = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		a[i + 1] = 0
		s += 1
print(s)


n = int(input())
b = list(map(int, input().split()))
dic = {}
li = []
b = [0] + b + [0]
count = 0
for i in range(1, n + 1):
	if b[i] == 0 and b[i - 1] == b[i + 1] == 1:
		b[i + 1] = 0
		count += 1
print(count)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def lmii():
	return list(map(int, input().split()))
n = int(input())
s = ''.join(input().split())
print(s.count('101'))


n = int(input())
x = list(map(int, input().split()))
k = 0
for i in range(n - 2):
	if x[i] == 1 and x[i + 1] == 0 and (x[i + 2] == 1):
		k += 1
		x[i + 2] = 0
print(k)


n = int(input())
lista = list(map(int, input().split(' ')))
off = []
for i in range(1, n - 1):
	if lista[i] == 0:
		if lista[i - 1] == 1 and lista[i + 1] == 1:
			off.append(i)
result = len(off)
x = len(off) - 1
i = 0
while i < x:
	if off[i + 1] == off[i] + 2:
		result -= 1
		off.pop(i + 1)
		x = x - 1
	else:
		i += 1
print(result)


x = int(input())
y = input()
z = y.split()
w = [d for d in z]
s = ''
for num in w:
	s = s + num
print(s.count('101'))


n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(1, n - 1):
	if a[i] == 0:
		if a[i - 1] == 1 and a[i + 1] == 1:
			a[i + 1] = 0
			c += 1
print(c)


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
n = I()
A = readInts()
i = 1
ans = 0
while i < n - 1:
	if A[i] == 0:
		if A[i - 1] == 1 and A[i + 1] == 1:
			ans += 1
			i += 3
		else:
			i += 1
	else:
		i += 1
print(ans)


def get_all_double_disturbing(lights):
	result = []
	for i in range(2, len(lights) - 2):
		if not is_double_disturbing(i, lights):
			continue
		result.append(i)
	return result

def is_disturbed(idx, lights):
	if idx == 0 or idx == len(lights) - 1:
		return False
	return not lights[idx] and lights[idx - 1] and lights[idx + 1]

def is_double_disturbing(idx, lights):
	return lights[idx] and lights[idx - 2] and lights[idx + 2] and (not lights[idx - 1]) and (not lights[idx + 1])
n = int(input())
lights = [x == '1' for x in input().split()]
double_disturbing = get_all_double_disturbing(lights)
k = 0
for dd in double_disturbing:
	if not is_double_disturbing(dd, lights):
		continue
	lights[dd] = 0
	k += 1
result = k + sum([is_disturbed(x, lights) for x in range(len(lights))])
print(result)


n = int(input())
s = input().replace(' ', '')
print(s.count('101'))


a = int(input())
c = list(map(int, input().split()))
k = 0
for j in range(a):
	if j + 1 != a and j != 0:
		if c[j] == 0 and c[j + 1] == 1 and (c[j - 1] == 1):
			k += 1
			c[j + 1] = 0
print(k)


k = 0
n = int(input())
a = list(map(int, input().split()))
for _ in range(1, n - 1):
	if a[_ - 1] == 1 and a[_] == 0 and (a[_ + 1] == 1):
		k += 1
		a[_ + 1] = 0
print(k)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
za = getIntList()
re = 0
for i in range(1, N - 1):
	if za[i] == 0 and za[i - 1] == 1 and (za[i + 1] == 1):
		re += 1
		za[i + 1] = 0
print(re)


a = int(input())
l = [int(k) for k in input().split()]
cancer = 0
for i in range(1, a - 1):
	if not l[i] and (l[i - 1] and l[i + 1]):
		l[i + 1] = 0
		cancer += 1
print(cancer)


import sys
n = int(input())
a = input().split()
a = [int(item) for item in a]
f = [1, 0, 1]
v = []
ans = 0
for i in range(n - 2):
	v.append(a[i:i + 3])
if not f in v:
	print(0)
	sys.exit()
if len(v) == 1:
	if f in v:
		print(1)
	else:
		print(0)
	sys.exit()
for i in range(len(v) - 2):
	if v[i] == v[i + 2] == f:
		v[i + 2][0] = 0
		ans += 1
		continue
	if v[i] == f:
		ans += 1
if v[-2]:
	if v[-2] == f:
		ans += 1
if v[-1] == f:
	ans += 1
print(ans)


n = int(input())
a = input()
ans = a.count('1 0 1')
print(ans)


a = int(input())
strIn = ''.join(input().split())
countx = 0
while True:
	idx = strIn.find('101')
	if idx == -1:
		break
	if idx + 3 >= len(strIn):
		countx += 1
		break
	strIn = strIn[:idx + 2] + '0' + strIn[idx + 3:]
	countx += 1
print('{}'.format(countx))


n = int(input())
arr = list(map(int, input().split()))
k = 0
for i in range(1, n - 1):
	if arr[i - 1] == 1 and arr[i + 1] == 1 and (arr[i] == 0):
		k += 1
		arr[i + 1] = 0
print(k)


n = int(input())
u = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if u[i] == 0 and u[i - 1] == 1 and (u[i + 1] == 1):
		ans += 1
		u[i + 1] = 0
print(ans)


n = int(input())
a = list(map(int, input().split()))
conf = []
ans = 0
for i in range(1, n - 1):
	if a[i] != a[i - 1] == a[i + 1] == 1:
		conf.append(i)
		ans += 1
i = 0
while i < len(conf):
	if conf[i] - conf[i - 1] == 2:
		ans -= 1
		conf.pop(i)
		conf.pop(i - 1)
		i -= 1
	i += 1
print(ans)


n = int(input())
A = [int(s) for s in input().split(' ') if s != '']
ret = 0
for i in range(1, len(A) - 1):
	if A[i] == 0 and A[i - 1] == 1 and (A[i + 1] == 1):
		A[i + 1] = 0
		ret += 1
print(ret)


def main():
	buf = input()
	n = int(buf)
	buf = input()
	buflist = buf.split()
	a = list(map(int, buflist))
	disturbed = []
	for i in range(1, n - 1):
		if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
			disturbed.append(i)
	k = 0
	remaining = list(disturbed)
	for i in disturbed:
		if not i in remaining:
			continue
		remaining.remove(i)
		if i + 2 in remaining:
			remaining.remove(i + 2)
		k += 1
	print(k)
main()


import sys

def rint():
	return map(int, sys.stdin.readline().split())
n = int(input())
a = list(rint())
cnt = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		a[i + 1] = 0
		cnt += 1
print(cnt)


input()
print(input().replace(' ', '').count('101'))


n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(2, n):
	if a[i] == a[i - 2] and a[i] == 1 and (a[i - 1] == 0):
		a[i] = 0
		res += 1
print(res)


n = int(input())
l = str(input())
l = l.replace(' ', '')
a = []
for i in range(len(l)):
	a.append(int(l[i]))
i = 1
k = 0
while i < n - 1:
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		k += 1
		i += 3
	else:
		i += 1
print(k)


import sys

def docalc(ass):
	disturbed = [i for i in range(1, len(ass) - 1) if ass[i] == 0 and ass[i - 1] == 1 and (ass[i + 1] == 1)]
	if len(disturbed) == 0:
		return 0
	k = 1
	di = disturbed[0]
	for d in disturbed[1:]:
		if d - di > 2:
			k += 1
			di = d
	return k

def main():
	n = int(sys.stdin.readline())
	ass = [int(i) for i in sys.stdin.readline().split()]
	print(docalc(ass))
main()


from copy import deepcopy
n = int(input())
a = list(map(int, input().split()))
ans = 0
k1 = k2 = 0
temp = deepcopy(a)
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == a[i + 1] == 1:
		a[i + 1] = 0
		k1 += 1
for i in range(n - 2, 0, -1):
	if temp[i] == 0 and temp[i - 1] == 1 == temp[i + 1] == 1:
		temp[i - 1] = 0
		k2 += 1
print(min(k1, k2))


n = int(input())
T = input().split(' ')
for i in range(n):
	T[i] = int(T[i])
m = 0
for i in range(1, n - 1):
	if T[i - 1] == 1 and T[i] == 0 and (T[i + 1] == 1):
		m += 1
		T[i + 1] = 0
print(m)


n = int(input())
lights = [int(i) for i in input().split(' ')]
ans = 0
for i in range(1, n - 1):
	if lights[i] == 0 and lights[i - 1] == 1 and (lights[i + 1] == 1):
		lights[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
(x, count) = (list(map(int, input().split(' '))), 0)
for i in range(1, n - 1):
	if x[i] == 0:
		if x[i + 1] == x[i - 1] == 1:
			count += 1
			x[i + 1] = 0
print(count)


i = int(input())
s = input()
print(s.count('1 0 1'))


n = int(input())
a = list(map(int, input().split()))

def che(a, n):
	a2 = a[:]
	i = 1
	ans = 0
	while i < n - 2:
		if a2[i - 1] == 1 and a2[i + 1] == 1 and (a2[i] == 0):
			ans += 1
			a2[i + 1] = 0
		i += 1
	if a2[-3:] == [1, 0, 1]:
		ans += 1
	return ans
ans = che(a, n)
a.reverse()
ans2 = che(a, n)
B = [0] * 10000
for i in range(100):
	B[i] = 1
print(min(ans, ans2))


import sys
import math
import bisect
import itertools
import random

def main():
	n = int(input())
	A = list(map(int, input().split()))
	ans = 0
	for i in range(2, n):
		if A[i - 2] == 1 and A[i - 1] == 0 and (A[i] == 1):
			A[i] = 0
			ans += 1
	print(ans)
main()


n = int(input())
a = [int(i) for i in input().split()]
cont = 0
for i in range(1, len(a) - 1):
	if a[i - 1:i + 2] == [1, 0, 1]:
		a[i + 1] = 0
		cont += 1
print(cont)


n = int(input())
m = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
	if m[i] == 0 and m[i + 1] == m[i - 1] == 1:
		cnt += 1
		m[i + 1] = 0
print(cnt)


import math
from collections import defaultdict
ii = lambda : int(input())
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ip = lambda : list(input())
t = ii()
a = ll()
ans = 0
for i in range(1, t - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		ans += 1
		a[i + 1] = 0
print(ans)


n = int(input())
arr = [int(p) for p in input().split()]
count = 0
for i in range(1, len(arr) - 1):
	if arr[i] == 0 and arr[i - 1] == 1:
		if arr[i + 1] == 1:
			arr[i + 1] = 0
			count += 1
print(count)


import sys
n = int(sys.stdin.readline())
p = list(map(int, sys.stdin.readline().split(' ')))
dis = [0] + [1 if p[i - 1] == 1 and p[i] == 0 and (p[i + 1] == 1) else 0 for i in range(1, n - 1)] + [0]
ans = 0
for i in range(1, n - 1):
	if dis[i - 1] == 1 and dis[i + 1] == 1:
		ans = ans + 1
		dis[i - 1] = dis[i + 1] = 0
for i in range(1, n):
	if dis[i - 1] == 1 or (i < n - 1 and dis[i + 1] == 1):
		ans = ans + 1
	if dis[i - 1] == 1:
		dis[i - 1] = 0
	elif i < n - 1 and dis[i + 1] == 1:
		dis[i + 1] = 0
print(ans)


n = int(input())
l = list(map(int, input().split()))
d = {}
count = 0
for i in range(1, len(l) - 1):
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		l[i + 1] = 0
		count = count + 1
print(count)


n = int(input())
s = input()
print(s.count('1 0 1'))


n = int(input())
a = [int(i) for i in input().split()]
k = 0
for i in range(2, n):
	if a[i] == 1 and a[i - 1] == 0 and (a[i - 2] == 1):
		a[i] = 0
		k += 1
print(k)


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
n = iinp()
pisos = lient()
if sum(pisos) == n or sum(pisos) == 0:
	print(0)
else:
	cont = 0
	for i in range(1, n - 1):
		if pisos[i] == 0:
			if pisos[i - 1] and pisos[i + 1]:
				pisos[i + 1] = 0
				cont += 1
	print(cont)


numHouses = input()
block = ''.join(input().split())
print(block.count('101'))


n = int(input())
if n <= 2:
	print(0)
else:
	ans_cnt = 0
	arrs = list(map(int, input().split()))
	for (i, cur) in enumerate(arrs):
		if i == 0 or i == len(arrs) - 1:
			continue
		if cur == 0:
			if arrs[i - 1] == 1 and arrs[i + 1] == 1:
				ans_cnt += 1
				arrs[i + 1] = 0
	print(ans_cnt)


I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
a = LI()
ans = 0
for i in range(0, n - 2):
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1):
		ans += 1
		a[i + 2] = 0
print(ans)


num = int(input())
light_list = input().split()
counter = 0
for i in range(1, num - 1):
	if light_list[i] == '0' and light_list[i - 1] == '1' and (light_list[i + 1] == '1'):
		counter += 1
		light_list[i + 1] = 0
print(counter)


n = int(input())
ai = list(map(int, input().split()))
disturbed = []
k = 0
for i in range(1, n - 1):
	if ai[i - 1:i + 2] == [1, 0, 1]:
		if i - 2 in disturbed:
			disturbed[-1] = i - 1
		else:
			disturbed.append(i)
if len(disturbed) == 0:
	print(0)
else:
	print(len(disturbed))


a = int(input())
ans = 0
l = list(map(int, input().split()))
l.reverse()
for i in range(1, len(l) - 1):
	if l[i - 1] == 1 and l[i] == 0 and (l[i + 1] == 1):
		l[i - 1] = 0
		l[i + 1] = 0
		ans += 1
print(ans)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
n = get_int()
lst = get_int_list()
count = 0
for i in range(1, n - 1):
	if lst[i] == 0 and lst[i - 1] == lst[i + 1] == 1:
		count += 1
		lst[i + 1] = 0
print(count)


n = int(input())
lst = list(map(int, input().split()))
rs = 0
for i in range(1, n - 1):
	if lst[i - 1] == 1 and lst[i + 1] == 1 and (lst[i] == 0):
		lst[i + 1] = 0
		rs += 1
print(rs)


n = int(input())
a = list(input().split(' '))
count = 0
for i in range(2, n):
	if a[i - 2:i + 1] == ['1', '0', '1']:
		count += 1
		a[i] = '0'
print(count)


n = int(input())
l = list(map(int, input().split()))
cou = 0
for i in range(0, len(l)):
	if i + 1 < n and i + 2 < n and (l[i] == 1) and (l[i + 1] == 0) and (l[i + 2] == 1):
		cou += 1
		l[i + 2] = 0
print(cou)


n = int(input())
t = list(map(int, input().split()))
i = 1
z = 0
while i < n - 1:
	if t[i] == 0 and t[i - 1] == t[i + 1] == 1:
		z += 1
		if i + 3 < n:
			if t[i + 2] == 0 and t[i + 3] == 1:
				i += 3
	i += 1
print(z)


n = int(input())
flats = str(input())
flats = ''.join(flats.split())
print(flats.count('101'))


def main():
	n = int(input())
	s = input().replace(' ', '')
	s = list(s)
	ans = 0
	for c in range(n):
		if s[c] == '1' and c + 1 < n and (c + 2 < n) and (s[c + 1] == '0') and (s[c + 2] == '1'):
			ans += 1
			s[c + 2] = '0'
	print(ans)
main()


n = int(input())
flats = list(map(int, input().split()))
counter = 0
i = 1
while i < n - 1:
	if flats[i - 1] == 1 and flats[i + 1] == 1 and (flats[i] == 0):
		counter += 1
		i += 2
	i += 1
print(counter)


n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(2, n):
	if a[i - 2] == 1 and a[i - 1] == 0 and (a[i] == 1):
		b.append(i)
k = 0
h = -1
j = False
for el in b:
	if h == el - 2 and (not j):
		j = True
	else:
		k += 1
		j = False
	h = el
print(k)


n_neighbors = int(input())
neighborhood = input().split(' ')
num_turn_offs = 0
for i in range(1, len(neighborhood) - 1):
	if neighborhood[i] == '0':
		if neighborhood[i - 1] == '1' and neighborhood[i + 1] == '1':
			neighborhood[i + 1] = '0'
			num_turn_offs += 1
print(num_turn_offs)


n = int(input())
lst = list(map(int, input().strip().split()))[:n]
counter = 0
for i in range(n - 2):
	if lst[i] == 1 and lst[i + 1] == 0 and (lst[i + 2] == 1):
		counter += 1
		lst[i + 2] = 0
print(counter if counter > 0 else 0)


n = eval(input())
numbers = [eval(i) for i in input().split(' ')]
ans = 0
for i in range(1, n - 1):
	if numbers[i - 1] and (not numbers[i]) and numbers[i + 1]:
		numbers[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
a = [int(v) for v in input().split()]
ans = 0
for i in range(n - 2):
	if a[i] and (not a[i + 1]) and a[i + 2]:
		ans += 1
		if a[i + 2]:
			a[i + 2] = False
		else:
			a[i] = False
print(ans)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = 0
	for i in range(1, n - 1):
		if a[i - 1] == a[i + 1] and a[i - 1] == 1 and (a[i] == 0):
			d += 1
			(a[i - 1], a[i + 1]) = (0, 0)
	print(d)
main()


from sys import stdin
input = stdin.readline
n = int(input())
arr = [int(x) for x in input().split()]
dp = []
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i + 1] == 1 and (arr[i - 1] == 1):
		dp.append(i)
ans = 0
i = 0
l = len(dp)
while i < l:
	if i == l - 1:
		ans = ans + 1
		i = i + 1
	elif dp[i + 1] - dp[i] == 2:
		ans = ans + 1
		i = i + 2
	else:
		ans = ans + 1
		i = i + 1
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
ans = 0
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		arr[i + 1] = 0
		ans += 1
print(ans)


def main():
	n = int(input())
	a = [int(c) for c in input().split()]
	res = 0
	for i in range(2, n):
		if a[i] == 1 and a[i - 1] == 0 and (a[i - 2] == 1):
			a[i] = 0
			res += 1
	print(res)
main()


n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
	if arr[i] == 1 and arr[i + 1] == 0 and (arr[i + 2] == 1):
		arr[i + 2] = 0
		ans += 1
print(ans)


from sys import stdin, stdout
from math import *
from heapq import *

def main():
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	res = 0
	for i in range(2, n):
		if a[i] == 1 and a[i - 1] == 0 and (a[i - 2] == 1):
			res = res + 1
			a[i] = 0
	stdout.write(str(res))
	return 0
main()


n = int(input())
h = list(map(int, input().split()))
d = []
dnumb = 0
c = 0
for i in range(n - 2):
	if (h[i + 2] == 1 and h[i] == 1) and h[i + 1] == 0:
		d.append(i + 1)
		dnumb += 1
for j in range(dnumb - 1):
	if d[j + 1] - d[j] == 2:
		d[j + 1] = -1
		c -= 1
c += dnumb
print(c)


f = int(input())
v = [int(i) for i in input().split()]
f = f - 1
p = 1
quant = 0
while p < f:
	ant = v[p - 1]
	atual = v[p]
	prox = v[p + 1]
	if ant == 1:
		if atual == 0:
			if prox == 1:
				v[p + 1] = 0
				quant = quant + 1
				p = p + 1
	p = p + 1
print(quant)


n = int(input())
a = list(map(int, input().split()))
cnt = 0
i = 0
while i < n:
	if i + 1 < n and i + 2 < n and (a[i] == 1) and (a[i + 1] == 0) and (a[i + 2] == 1):
		cnt = cnt + 1
		a[i + 2] = 0
	i = i + 1
print(cnt)


n = int(input())
flats = list(map(int, input().split()))
should_turnoff = 0
for i in range(1, len(flats) - 1):
	if flats[i] == 0 and flats[i - 1] == 1 and (flats[i + 1] == 1):
		should_turnoff += 1
		flats[i + 1] = 0
print(should_turnoff)


n = int(input())
a = list(map(int, input().split()))
k = 0
for i in range(1, n - 1):
	if a[i + 1] == a[i - 1] == 1 and a[i] == 0:
		a[i - 1] = 0
		s1 = 0
		for j in range(1, n - 1):
			if a[j + 1] == a[j - 1] == 1 and a[j] == 0:
				s1 += 1
		a[i - 1] = 1
		a[i + 1] = 0
		s2 = 0
		for j in range(1, n - 1):
			if a[j + 1] == a[j - 1] == 1 and a[j] == 0:
				s2 += 1
		a[i + 1] = 1
		if s1 > s2:
			a[i + 1] = 0
		else:
			a[i - 1] = 0
		k += 1
print(k)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def main():
	input()
	li = [0] + get_list() + [0]
	res = 0
	for i in range(1, len(li) - 1):
		if li[i] == 0 and li[i - 1] == 1 and (li[i + 1] == 1):
			li[i + 1] = 0
			res += 1
	print(res)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


n = int(input())
a = list(map(int, input().split()))
c = 0
for j in range(1, n - 1):
	if j == n - 1:
		if a[j] == 0 and a[j - 1] == 1 and (a[j + 1] == 1):
			a[j - 1] = 0
			c = c + 1
	elif a[j] == 0 and a[j - 1] == 1 and (a[j + 1] == 1):
		a[j + 1] = 0
		c = c + 1
print(c)


amount = int(input())
array = [int(s) for s in input().split()]
counter = 0
i = 0
for i in range(len(array) - 2):
	if array[i] == 1 and array[i + 1] == 0 and (array[i + 2] == 1):
		array[i + 2] = 0
		counter += 1
print(counter)


n = int(input())
arr = [int(x) for x in input().split()]
k = 0
for i in range(2, n - 2):
	if arr[i] == 1 and (arr[i - 1] == 0 and arr[i - 2] == 1) and (arr[i + 1] == 0 and arr[i + 2] == 1):
		arr[i] = 0
		k += 1
for i in range(1, n - 1):
	if arr[i] == 0 and (arr[i - 1] == 1 and arr[i + 1] == 1):
		arr[i - 1] = 0
		k += 1
print(k)


n = int(input())
arr = list(map(int, input().split(' ')))
ans = 0
for i in range(len(arr)):
	if i == 0 or i == n - 1:
		continue
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		arr[i + 1] = 0
		ans = ans + 1
print(ans)


from math import ceil
c = 1
n = int(input())
a = [int(i) for i in input().split()]
s = [0] * n
p = []
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		s[i] += 1
t = sum(s)
for i in range(1, n - 2):
	if s[i] == 1 and s[i + 2] == 1:
		c = c + 1
	elif s[i] == 1 and s[i + 2] != 1 and (c > 1):
		p.append(c)
		c = 1
if c > 1:
	p.append(c)
su1 = sum(p)
total = t - su1 + ceil(sum(p) / 2)
print(total)


import math
import bisect
import itertools
import sys
mod = 10 ** 9 + 7

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s
n = int(input())
a = list(map(int, input().split()))
i = 1
count = 0
while i < n - 1:
	if a[i] == 0 and a[i + 1] == 1 and (a[i - 1] == 1):
		count += 1
		a[i + 1] = 0
	else:
		i += 1
print(count)


n = int(input())
v = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
	if v[i - 1] == 1 and v[i + 1] == 1 and (v[i] == 0):
		count += 1
		v[i + 1] = 0
print(count)


import copy

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	solver(a)

def solver(a):
	count = 0
	aCopy = copy.copy(a)
	for i in range(1, len(a) - 1):
		if aCopy[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
			aCopy[i + 1] = 0
			count += 1
	print(count)
main()


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
lens = read_int()
arrs = read_strs()
cnt = 0
i = 0
while i < lens - 2:
	if arrs[i] == '1' and arrs[i + 1] == '0' and (arrs[i + 2] == '1'):
		cnt += 1
		i += 3
	else:
		i += 1
print(cnt)


n = int(input())
l1 = [int(x) for x in input().split()]
i = 0
ans = 0
while i < len(l1) - 2:
	if l1[i] == 1 and l1[i + 1] == 0 and (l1[i + 2] == 1):
		l1[i + 2] = 0
		ans += 1
	i += 1
print(ans)


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
from collections import defaultdict
(n, a, ans) = (int(input()), arr_inp(), 0)
for i in range(1, n - 1):
	if a[i - 1] and a[i + 1] and (a[i] == 0):
		a[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
count = 0
i = 1
while i < n - 1:
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		i = i + 3
		count = count + 1
	else:
		i = i + 1
print(count)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
arr = input().split()
dis = []
for i in range(1, n - 1):
	if int(arr[i]) == 0:
		if int(arr[i + 1]) == 1 and int(arr[i - 1]) == 1:
			dis.append(i)
p = len(dis)
j = 0
count = 0
while j < p:
	if j + 1 < p and dis[j + 1] - dis[j] == 2:
		count += 1
		j += 2
	else:
		count += 1
		j += 1
print(count)


b = int(input())
a = list(map(int, input().split()))
sss = 0
for x in range(b - 2):
	if a[x] == 1 and a[x + 1] == 0 and (a[x + 2] == 1):
		a[x + 2] = 0
		sss += 1
print(sss)


n = int(input())
aps = list(map(int, input().split()))
m = 0
i = 1
while i < n - 1:
	if aps[i - 1] == 1 and aps[i] == 0 and (aps[i + 1] == 1):
		m += 1
		aps[i + 1] = 0
	i += 1
print(m)


n = int(input())
l = [int(i) for i in input().split()]
ans = 0
for i in range(2, n - 2):
	if l[i] == l[i - 2] == l[i + 2] == 1 and l[i - 1] == l[i + 1] == 0:
		ans += 1
		l[i] = 0
for i in range(1, n - 1):
	if l[i - 1] == l[i + 1] == 1 and l[i] == 0:
		ans += 1
		l[i + 1] = 1
print(ans)


n = int(input())
l = [*map(int, input().split())]
cnt = 0
for i in range(n):
	if i >= 2 and l[i - 2] == 1 and (l[i - 1] == 0) and (l[i] == 1):
		l[i] = 0
		cnt += 1
print(cnt)


n = eval(input())
i = input()
i = [int(z) for z in i.split(' ')]
k = 0
for x in range(1, n - 1):
	if i[x - 1] == 1 and i[x] == 0 and (i[x + 1] == 1):
		i[x + 1] = 0
		k += 1
print(k)


n = int(input())
a = list(map(int, input().split()))

def check(a, n):
	a2 = a[:]
	i = 1
	ans = 0
	while i < n - 2:
		if a2[i - 1] == 1 and a2[i + 1] == 1 and (a2[i] == 0):
			ans += 1
			a2[i + 1] = 0
		i += 1
	if a2[-3:] == [1, 0, 1]:
		ans += 1
	return ans
ans = check(a, n)
a.reverse()
ans2 = check(a, n)
print(min(ans, ans2))


n = int(input())
a = list(map(int, input().split()))
f = 0
b = []
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] and a[i + 1]:
		b += [i]
k = 0
for i in range(len(b) - 1):
	if b[i + 1] != b[i] + 2 or k:
		f += 1
		k = 0
	else:
		k = 1
if b:
	f += 1
print(f)


n = int(input())
arr = list(map(int, input().split()))
b = []
for i in range(len(arr)):
	if i != 0 and i != len(arr) - 1:
		if arr[i - 1] == 1 and arr[i] == 0 and (arr[i + 1] == 1):
			b.append(i + 1)
ans = 0
for i in range(len(b)):
	if i != len(b) - 1 and b[i + 1] - b[i] > 2 and (b[i] != 0) and (b[i + 1] != 0):
		b[i] = 0
		ans += 1
	elif i != len(b) - 1 and b[i + 1] - b[i] == 2 and (b[i] != 0) and (b[i + 1] != 0):
		b[i] = 0
		b[i + 1] = 0
		ans += 1
	elif b[i] != 0:
		b[i] = 0
		ans += 1
print(ans)


int(input())
a = list(map(lambda s: s.strip() == '1', input().split(' ')))
k = 0
for i in range(1, len(a) - 1):
	if not a[i] and a[i - 1] and a[i + 1]:
		a[i + 1] = False
		k += 1
print(k)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1, n - 1):
	if a[i - 1] == a[i + 1] == 1 and a[i] == 0:
		b.append(i)
c = 0
i = 0
while b:
	if len(b) > 1:
		if b[0] == b[1] - 2:
			c += 1
			b.pop(0)
			b.pop(0)
		else:
			c += 1
			b.pop(0)
	else:
		c += 1
		b.pop(0)
print(c)


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if not a[i] and a[i - 1] == a[i + 1] == 1:
		ans += 1
		a[i + 1] = 0
print(ans)


import math
alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
a = list(map(int, input().split()))
E = 0
for i in range(1, n - 1):
	if a[i - 1] * a[i + 1] == 1 and a[i] == 0:
		E += 1
		a[i + 1] = 0
print(E)


n = int(input())
a = [int(s) for s in input().split()]
k = 0
b = []
c = [0] * n
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		b.append(i)
		c[i] = 1
for i in range(len(b) - 1):
	if c[b[i]] == 1:
		if abs(b[i] - b[i + 1]) >= 3:
			k += 1
			c[b[i]] = 0
		else:
			k += 1
			c[b[i]] = 0
			c[b[i + 1]] = 0
print(k + c.count(1))


a = int(input(''))
b = str(input(''))
print(b.count('1 0 1'))


n = int(input())
v = []
linie = input()
for nr in linie.split():
	v.append(int(nr))
k = 0
for i in range(1, n - 1, 1):
	if v[i - 1] == 1 and v[i + 1] == 1 and (v[i] == 0):
		v[i + 1] = 0
		k += 1
print(k)


n = int(input())
listt = input().split(' ')
i = 0
count = 0
while i < n:
	if i + 4 < n:
		if int(listt[i]) == 1 and int(listt[i + 1]) == 0 and (int(listt[i + 2]) == 1) and (int(listt[i + 3]) == 0) and (int(listt[i + 4]) == 1):
			count = count + 1
			i = i + 4
			continue
	if i + 2 < n:
		if int(listt[i]) == 1 and int(listt[i + 1]) == 0 and (int(listt[i + 2]) == 1):
			count = count + 1
			i = i + 2
		else:
			i = i + 1
	else:
		i = i + 1
print(count)


n = int(input())
flats = [int(c) for c in input().split()]
total = 0
i = 1
while i < n - 1:
	if not flats[i] and (flats[i - 1] and flats[i + 1]):
		flats[i + 1] = 0
		total += 1
		i = i + 3
	else:
		i = i + 1
print(total)


def process(A, n):
	d = 0
	temp = []
	for i in range(1, len(A) - 1):
		if A[i - 1] == 1 and A[i] == 0 and (A[i + 1] == 1):
			d = d + 1
			temp.append(i)
	temp1 = 0
	i = 1
	while True:
		if i > len(temp) - 1:
			break
		if temp[i] - temp[i - 1] == 2:
			temp1 = temp1 + 1
			i = i + 2
		else:
			i = i + 1
	return d - temp1
n = int(input())
A = [int(x) for x in input().split()]
print(process(A, n))


ints = lambda line: [int(x) for x in line.split()]
(n, flats, k) = (int(input()), ints(input()), 0)
for i in range(1, n - 1):
	if flats[i - 1] and flats[i + 1] and 1 - flats[i]:
		(k, flats[i + 1]) = (k + 1, 0)
print(k)


n = int(input())
a = list(map(int, input().split()))
an = 0
m = 1
while m < n - 1:
	if not a[m]:
		if a[m - 1] and a[m + 1]:
			if m + 2 < n and (not a[m + 2]):
				an += 1
				m += 4
			else:
				an += 1
				m += 3
		else:
			m += 1
	else:
		m += 1
print(an)


def B():
	n = int(input())
	lights = [int(x) for x in input().split()]
	count = 0
	for i in range(1, n - 1):
		if lights[i - 1] == lights[i + 1] == 1 and lights[i] == 0:
			lights[i + 1] = 0
			count += 1
	print(count)
B()


from sys import stdin, stdout
N = int(input())
arr = [int(x) for x in stdin.readline().split()]
ones = 0
res = 0
for i in range(N):
	if arr[i] == 1:
		if ones == 1 and i > 1:
			ones += 1
			res += 1
		else:
			ones = 0
	else:
		ones += 1
print(res)


n = int(input())
A = [int(i) for i in input().split()]
V = []
for i in range(n - 2):
	if A[i] == 1 and A[i + 1] == 0 and (A[i + 2] == 1):
		V.append(i + 1)
V.append(1000)
k = 0
l = 0
n = len(V)
for i in range(n):
	if V[i] - V[l] != 2:
		d = i - l
		k += (d + 1) // 2
		l = i
print(k)


z = int(input())
x = list(map(int, input().split()))
q = 0
for i in range(1, z - 1):
	if x[i - 1] == x[i + 1] and x[i - 1] == 1 and (x[i] == 0):
		x[i + 1] = 0
		q += 1
print(q)


n = int(input())
house = list(map(int, input().split()))
k = 0
for i in range(1, n - 1):
	prev = house[i - 1]
	cur = house[i]
	next = house[i + 1]
	if cur == 0 and prev == next == 1:
		house[i + 1] = 0
		k = k + 1
print(k)


I = lambda : map(int, input().split())
n = int(input())
a = list(I())
c = 0
i = 1
while i < n - 1:
	if not a[i]:
		if a[i - 1] and a[i + 1]:
			if i + 2 < n and (not a[i + 2]):
				c += 1
				i += 4
			else:
				c += 1
				i += 3
		else:
			i += 1
	else:
		i += 1
print(c)


n = int(input())
x = list(map(int, input().split()))
d = {}
m = {}
for i in range(1, len(x) - 1):
	if x[i] == 0 and x[i - 1] == 1 and (x[i + 1] == 1):
		m[i] = 1
		try:
			d[i - 1] += 1
		except:
			d[i + 1] = 1
c = 0
for i in d:
	if d[i] == 2:
		m.pop(i + 1)
		m.pop(i - 1)
		c += 1
print(c + len(m))


n = int(input())
a = list(map(int, input().split()))
c = 0
i = 1
while i < n - 1:
	if not a[i]:
		if a[i - 1] and a[i + 1]:
			c += 1
			i += 2
	i += 1
print(c)


total_flats = int(input())
flats = input()
count = 0
while '1 0 1' in flats:
	flats = flats.replace('1 0 1', '', 1)
	count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
pos = []
ans = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		if len(pos) and pos[-1] == i - 2:
			pos.pop()
		else:
			ans += 1
			pos.append(i)
print(ans)


def main():
	t = int(input())
	l = [x == '1' for x in input().split(' ')]
	s = 0
	for i in range(1, t - 1):
		if l[i - 1] and (not l[i]) and l[i + 1]:
			s += 1
			l[i + 1] = 0
	print(s)
main()


N = int(input())
flat = [int(x) for x in input().split()]
disturbed = []
for i in range(1, len(flat) - 1):
	if flat[i] == 0 and flat[i - 1] == 1 and (flat[i + 1] == 1):
		disturbed.append(i)
if len(disturbed) > 0:
	disturbed_linked = []
	conjunto = 1
	if len(disturbed) > 1:
		for i in range(1, len(disturbed)):
			if disturbed[i] - disturbed[i - 1] == 2:
				conjunto += 1
				if i == len(disturbed) - 1:
					disturbed_linked.append(conjunto)
			else:
				disturbed_linked.append(conjunto)
				conjunto = 1
				if i == len(disturbed) - 1:
					disturbed_linked.append(conjunto)
	else:
		disturbed_linked.append(conjunto)
	soma = 0
	for i in disturbed_linked:
		if i == 1:
			soma += 1
		else:
			soma += int((i + 1) / 2)
	print(soma)
else:
	print(0)


n = int(input())
a = input().split()
k = 0
for i in range(1, n - 1):
	if a[i - 1] == '1' == a[i + 1] and a[i] == '0':
		k += 1
		a.pop(i - 1)
		a.insert(i - 1, '0')
		a.pop(i + 1)
		a.insert(i + 1, '0')
print(k)


import sys
n = int(sys.stdin.readline())
a = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

def is_worried(i):
	if i == 0 or i == n - 1:
		return False
	return a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0)
count = 0
for i in range(1, n - 1):
	if is_worried(i):
		count += 1
		a[i + 1] = 0
print(count)


from sys import stdin, stdout

def solve(flats, n):
	result = 0
	for i in range(n - 2):
		if flats[i] == flats[i + 2] == 1:
			if flats[i + 1] == 0:
				flats[i + 2] = 0
				result += 1
	return result
n = int(stdin.readline().rstrip())
flats = list(map(int, stdin.readline().rstrip().split()))
stdout.write(str(solve(flats, n)))


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
n = int(input())
l = list(numIN())
cnt = 0
for i in range(1, n - 1):
	if l[i] == 0:
		if l[i + 1] == 1 and l[i - 1] == 1:
			l[i + 1] = 0
			cnt += 1
print(cnt)


import sys
n = int(sys.stdin.readline().strip())
A = [int(i) for i in sys.stdin.readline().strip().split()]
k = 0
for i in range(1, n - 1):
	if A[i - 1] == A[i + 1] == 1 and A[i] == 0:
		A[i + 1] = 0
		k = k + 1
print(k)


n = int(input())
a = list(input().split())
a = ''.join(a)
b = a[::-1]
ca = 0
cb = 0
while '101' in a or '101' in b:
	try:
		k = a.index('101')
		a = list(a)
		a[k] = '0'
		a[k + 1] = '0'
		a[k + 2] = '0'
		ca += 1
		a = ''.join(a)
	except:
		i = 1
	try:
		k = b.index('101')
		b = list(b)
		b[k] = '0'
		b[k + 1] = '0'
		b[k + 2] = '0'
		cb += 1
		b = ''.join(b)
	except:
		i = 1
print(min(ca, cb))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
l = list(map(int, str(input()).split()))

def turn_off(l, k, disturbed):
	if k == n - 1:
		return disturbed
	elif l[k]:
		return turn_off(l, k + 1, disturbed)
	elif l[k - 1] and l[k + 1]:
		l[k + 1] = 0
		return turn_off(l, k + 1, disturbed + 1)
	else:
		return turn_off(l, k + 1, disturbed)
disturbed = turn_off(l, 1, 0)
print(disturbed)


a = int(input())
z = []
k = 0
c = list(map(int, input().split()))
for i in range(1, a - 1):
	if c[i] == 0 and c[i - 1] == c[i + 1] == 1:
		if i - 1 not in z and i + 1 not in z:
			z += [i - 1, i + 1]
			k += 1
print(k)


n = int(input())
print(max(0, input().count('1 0 1')))


n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(len(a)):
	if a[i] == 0 and i != 0 and (i != len(a) - 1):
		if a[i + 1] == a[i - 1] == 1:
			a[i + 1] = 0
			s += 1
print(s)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
n = int(z())
l = list(map(int, z().split()))
c = 0
for i in range(1, n - 1):
	if l[i - 1] == l[i + 1] == 1 and l[i] == 0:
		c += 1
		l[i + 1] = 0
print(max(0, c))


n = int(input())
arr = list(map(int, input().split()))
i = 0
j = 2
c = 0
while i < n and j < n:
	if arr[i] == arr[j] and arr[j] == 1:
		if arr[i + 1] == 0:
			c += 1
			i += 3
			j += 3
			continue
		else:
			i += 1
			j += 1
	else:
		i += 1
		j += 1
print(c)


n = int(input())
p = list(map(int, input().split()))
for x in range(1):
	t = 1
	lim = 0
	if p.count(0) == 0:
		print(0)
	else:
		while t < n - 1:
			if p[t - 1] == 1 and p[t] == 0 and (p[t + 1] == 1):
				lim += 1
				p[t + 1] = 0
			else:
				pass
			t += 1
		print(lim)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
f = ai()
ans = 0
for i in range(1, n - 1):
	if f[i - 1] == 1 and f[i + 1] == 1 and (f[i] == 0):
		ans += 1
		f[i + 1] = 0
op(ans)


int(input())
print(''.join(input().split()).count('101'))


input()
k = x = y = 0
for z in map(int, input().split()):
	if x & ~y & z:
		k += 1
		z = 0
	(x, y) = (y, z)
print(k)


n = int(input())
a = [int(x) for x in input().split()]
ind = 0
consec = []
prev = -100
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		ind += 1
		if i - 2 == prev:
			consec[-1] += 1
		else:
			consec.append(1)
		prev = i
if ind == 0:
	print(ind)
else:
	ans = 0
	for i in consec:
		if i == 1:
			ans += 1
		elif i % 2 == 0:
			ans += i // 2
		else:
			ans += i // 2 + 1
	print(ans)


m = int(input())
l = list(map(int, input().split()))
v = 1
c = 0
while v != len(l) - 1:
	if l[v - 1] == 1 and l[v] == 0 and (l[v + 1] == 1):
		c += 1
		v += 3
	else:
		v += 1
	if v > len(l) - 1:
		break
print(c)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	cur = []
	answer = 0
	i = 1
	while i != n - 1:
		if a[i] == 0:
			if a[i - 1] == a[i + 1] == 1:
				cur.append(i + 1)
		i += 1
	if cur == []:
		return print(0)
	if len(cur) == 1:
		return print(1)
	j = 0
	used = 0
	while j <= len(cur) - 1:
		if cur[j + 1] - cur[j] == 2:
			answer += 1
			j += 2
			used += 2
		else:
			answer += 1
			j += 1
			used += 1
		if j >= len(cur) - 1:
			break
	if used == len(cur) - 1:
		answer += 1
	return print(answer)
main()


n = int(input())
A = list(map(int, input().split()))
ANS = 0
for i in range(1, n - 1):
	if A[i - 1] == 1 and A[i] == 0 and (A[i + 1] == 1):
		ANS += 1
		A[i + 1] = 0
print(ANS)


input()
flats = list(map(int, input().split()))
flatsb = flats.copy()
(kl, kr) = (0, 0)
for i in range(1, len(flats) - 1):
	if not flats[i] and flats[i - 1] and flats[i + 1]:
		flats[i - 1] = 0
		flats[i + 1] = 0
		kl += 1
flats = flatsb
for i in range(len(flats) - 2, 0, -1):
	if not flats[i] and flats[i - 1] and flats[i + 1]:
		flats[i - 1] = 0
		flats[i + 1] = 0
		kr += 1
print(min(kl, kr))


n = int(input())
numbers = list(map(int, input().split(' ')))
out = 0
for i in range(1, n - 1):
	if numbers[i] == 0:
		if numbers[i + 1] == 1 and numbers[i - 1] == 1:
			numbers[i + 1] = 0
			out += 1
print(out)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def safe(x, y, n, m):
	return 0 <= x < n and 0 <= y < m

def solve(case):
	n = int(inp())
	a = lis()
	ans = 0
	for i in range(1, n - 1):
		if a[i] == 1:
			continue
		if a[i - 1] == 1 and a[i + 1] == 1:
			ans += 1
			a[i + 1] = 0
	print(ans)
testcase(1)


n = int(input())
a = list(map(int, input().split()))
a.append(0)
k = 0
l = a[0]
m = a[1]
r = a[2]
for i in range(3, n + 1):
	if l == 1 and m == 0 and (r == 1):
		k += 1
		r = 0
	l = m
	m = r
	r = a[i]
print(k)


n = int(input())
a = list(map(int, input().split()))
r = 0
for i in range(1, n - 1):
	if a[i] == 1:
		continue
	if a[i - 1] == a[i + 1] == 1:
		r += 1
		a[i + 1] = 0
print(r)


n = int(input())
k = 0
b = []
a = list(map(int, input().split()))
for i in range(2, n):
	if not a[i - 1] and a[i - 2] and a[i]:
		a[i] = 0
		k += 1
print(k)


n = int(input())
l = input().split()
x = 0
count = 0
while x < n - 2:
	if l[x] == '1' and l[x + 1] == '0' and (l[x + 2] == '1'):
		count += 1
		x += 3
	else:
		x += 1
print(count)


n = int(input())
arr = list(map(int, input().strip().split()))
k = 0
i = 1
while i < n - 1:
	if arr[i] == 0:
		if arr[i - 1] == arr[i + 1] == 1:
			k += 1
			arr[i + 1] = 0
	i += 1
print(k)


n = eval(input())
a = list(map(int, input().split()))
i = 2
flat = 0
while i <= n - 3:
	if a[i] == 1 and a[i - 1] == 0 and (a[i + 1] == 0) and (a[i - 2] == 1) and (a[i + 2] == 1):
		a[i] = 0
		flat += 1
	i += 1
i = 1
while i < n - 1:
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		flat += 1
	i += 1
print(flat)


n = int(input())
l = input().split()
c = 0
for i in range(1, n - 1):
	if l[i] == '0':
		if l[i - 1] == '1' and l[i + 1] == '1':
			l[i + 1] = '0'
			c += 1
print(c)


def main():
	N = int(input())
	A = [int(i) for i in input().split()]
	ans = 0
	for i in range(N - 2):
		if A[i:i + 3] == [1, 0, 1]:
			ans += 1
			A[i + 2] = 0
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
count = 0
prevPos = -2
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
		if prevPos == i - 2:
			count = count + 1
			prevPos = -2
		elif prevPos == -2:
			prevPos = i
		else:
			count = count + 1
			prevPos = i
if prevPos != -2:
	count = count + 1
print(count)


n = int(input())
l = list(map(int, input().split()))
i = 1
c = 0
while i < len(l) - 1:
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		c += 1
		l[i + 1] = 0
	else:
		i += 1
print(c)


import sys
n = int(input())
a = list(map(int, input().split()))
k = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		k += 1
print(k)


def neighbours(lst, n):
	count = 0
	for i in range(len(lst)):
		if i - 1 >= 0 and i + 1 < len(lst) and (lst[i - 1] == lst[i + 1] == 1) and (lst[i] == 0):
			lst[i + 1] = 0
			count += 1
	return count
n = int(input())
a = [int(j) for j in input().split()]
print(neighbours(a, n))


n = int(input())
a = [int(x) for x in input().split()]
l = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		l = l + 1
i = 0
while i <= n - 5:
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1) and (a[i + 3] == 0) and (a[i + 4] == 1):
		l = l - 1
		i = i + 4
	else:
		i = i + 1
if l == 0:
	print(0)
else:
	print(l)


x = int(input())
p = list(map(int, input().split()))
y = 0
for i in range(1, x - 1):
	if p[i] == 0 and p[i + 1] == 1 and (p[i - 1] == 1):
		y += 1
		p[i + 1] = 0
print(y)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
a = list(map(int, input().split()))
cz = 0
for i in range(1, n - 1):
	if a[i] == 0:
		cz += 1
if cz == 0 or cz == n:
	print(0)
else:
	ans = 0
	for i in range(1, n - 1):
		if a[i] == 0 and a[i + 1] == 1 and (a[i - 1] == 1):
			a[i + 1] = 0
			ans += 1
	print(ans)


b = int(input())
ans = 0
a = list(map(int, input().split()))
for i in range(1, b - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
zs = []
for x in range(1, len(a) - 1):
	if a[x - 1] == 1 and a[x] == 0 and (a[x + 1] == 1):
		zs.append(x)
if len(zs) == 1:
	print(1)
else:
	ans = len(zs)
	for q in range(len(zs) - 1):
		if zs[q] > 0 and zs[q + 1] - zs[q] == 2:
			ans -= 1
			zs[q + 1] = -zs[q + 1]
	print(ans)


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())
n = f()
cl = f(2)
k = 0
for i in range(1, n - 1):
	if cl[i] == 0 and cl[i - 1] == 1 and (cl[i + 1] == 1):
		k += 1
		cl[i + 1] = 0
print(k)


input()
n = input().replace(' ', '')
ntmp = n + '55555'
three = 0
five = 0
for i in range(len(n) - 2):
	if ntmp[i:i + 3] == '101':
		three += 1
		k = 3
		add = True
		while ntmp[i + k:i + k + 2] == '01':
			if add:
				five += 1
				add = False
				k += 2
			else:
				five -= 1
				add = True
				k += 2
print(three - five)


n = int(input())
k = 0
bin_list = list([int(x) for x in input().split()])
prev_1 = bin_list[0]
prev_2 = bin_list[1]
for i in range(2, n):
	if bin_list[i] == 1 and prev_1 == 1 and (prev_2 == 0):
		bin_list[i] = 0
		k += 1
	prev_1 = prev_2
	prev_2 = bin_list[i]
print(k)


n = int(input())
a = ''.join(input().split())
print(a.count('101'))


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
ans = 0
for i in range(1, N - 1):
	if A[i - 1] == A[i + 1] == 1 and A[i] == 0:
		A[i + 1] = 0
		ans += 1
print(ans)


x = int(input())
y = [int(i) for i in input().split()]
z = 0
for i in range(1, x - 1):
	if y[i] == 0 and y[i - 1] == y[i + 1] == 1:
		y[i + 1] = 0
		z += 1
print(z)


import sys
n = int(input())
x = list(map(int, input().split()))
cnt = 0
for i in range(2, n - 2):
	if x[i - 2:i + 3] == [1, 0, 1, 0, 1]:
		cnt += 1
		x[i] = 0
for i in range(1, n - 1):
	if x[i - 1:i + 2] == [1, 0, 1]:
		cnt += 1
		x[i - 1] = 0
print(cnt)


n = int(input())
a = [int(d) for d in input().split()]
k = 0
for x in range(1, n - 1):
	if a[x - 1] == a[x + 1] and a[x - 1] == 1 and (a[x] == 0):
		a[x + 1] = 0
		k += 1
print(k)


from __future__ import division, print_function
import cmath
import itertools
import math
import operator as op
import sys
from atexit import register
from bisect import bisect_left, bisect_right
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
	from math import gcd
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)

	def gcd(x, y):
		while y:
			(x, y) = (y, x % y)
		return x
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	n = int(input())
	k = 0
	c = 0
	a = list(map(int, input().split()))
	temp = a.copy()
	for i in range(1, n - 1):
		if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
			a[i + 1] = 0
			k += 1
		if temp[i - 1] == 1 and temp[i + 1] == 1 and (temp[i] == 0):
			temp[i - 1] = 0
			c += 1
	print(min(k, c))
sync_with_stdio(False)
main()


n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.append(0)
a.append(0)
count = 0
for i in range(1, n - 1):
	if (a[i] == 0 and a[i - 1] == 1) and a[i + 1] == 1:
		count += 1
		if a[i + 2] == 0 and a[i + 3] == 1:
			a[i + 1] = 0
		else:
			a[i - 1] = 0
print(count)


n = int(input())
a = [int(x) for x in input().split(' ')]
k = 0
for i in range(n - 4):
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1) and (a[i + 3] == 0) and (a[i + 4] == 1):
		a[i + 2] = 0
		k += 1
for i in range(n - 2):
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1):
		a[i] = 0
		k += 1
print(k)


x = int(input())
w = input().split()
w = ''.join(w)
print(w.count('101'))


numHouses = int(input())
houses = list(map(lambda x: int(x), str(input()).split()))
numLightsToTurnOff = 0
i = 1
while i < numHouses - 1:
	if houses[i] == 0 and houses[i - 1] == 1 and (houses[i + 1] == 1):
		numLightsToTurnOff += 1
		if i + 2 < numHouses and houses[i + 2] == 0:
			i += 3
		else:
			i += 1
	else:
		i += 1
print(numLightsToTurnOff)


n = int(input())
l = list(map(int, input().split()))
dist = []
for i in range(1, n - 1, 1):
	if l[i - 1] == 1 and l[i + 1] == 1 and (l[i] == 0):
		dist.append(i)
cont = 0
i = 0
while i < len(dist):
	if i < len(dist) - 1 and dist[i + 1] - dist[i] == 2:
		i = i + 1
	i = i + 1
	cont = cont + 1
print(cont)


n = int(input())
string = input().strip().split(' ')
count = 0
for i in range(len(string) - 2):
	example = ''.join(string[i:i + 3])
	if example == '101':
		string[i + 2] = '0'
		count += 1
print(count)


f = open(0, 'r')
n = int(f.readline())
a = list(map(int, f.readline().split()))
c = 0
for i in range(1, n - 1):
	if a[i] != 0 or a[i - 1] != 1 or a[i + 1] != 1:
		continue
	a[i + 1] = 0
	c += 1
print(c)


import math
n = int(input())
lis = list(map(int, input().split()))
arr = []
count = 0
for i in range(1, n - 1):
	if lis[i] == 0 and lis[i - 1] == 1 and (lis[i + 1] == 1):
		count += 1
		lis[i + 1] = 0
print(count)


q = int(input())
ls = list(map(int, input().split()))
tot = 0

def isDist(i):
	if ls[i] == 0 and ls[i - 1] == 1 and (ls[i + 1] == 1):
		return True
	else:
		return False
for i in range(1, q - 1):
	if isDist(i):
		tot += 1
		ls[i + 1] = 0
print(tot)


n = int(input())
a = list(map(int, input().split()))
idx = -2
count = 0
i = 1
while i < n - 1:
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		if i - idx == 2:
			i += 2
			continue
		else:
			idx = i
			count += 1
			i += 2
	else:
		i += 1
print(count)


import math
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(2, n - 2):
	if l[i] == 1 and l[i - 1] == 0 and (l[i - 2] == 1) and (l[i + 1] == 0) and (l[i + 2] == 1):
		l[i] = 0
		ans += 1
for i in range(1, n - 1):
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		ans += 1
print(ans)


def main():
	n = int(input())
	flats = [int(x) for x in input().strip().split(' ')]
	k = 0
	for i in range(2, len(flats)):
		(a, b, c) = (flats[i - 2], flats[i - 1], flats[i])
		if a == c == 1 and b == 0:
			c = flats[i] = 0
			k += 1
	print(k)
main()


input()
print(input().count('1 0 1'))


n = int(input())
l = list(map(int, input().split()))
k = 0
for i in range(n - 2):
	if l[i:i + 3] == [1, 0, 1]:
		l[i + 2] = 0
		k += 1
print(k)


n = int(input())
A = list(map(int, input().split()))
B = [A[i] for i in range(n)]
ans = 0
for i in range(n - 2):
	if A[i:i + 3] == [1, 0, 1]:
		A[i + 2] = 0
		ans += 1
out = ans
A = [B[i] for i in range(n)]
ans = 0
for i in range(n - 3, -1, -1):
	if A[i:i + 3] == [1, 0, 1]:
		A[i] = 0
		ans += 1
out = min(out, ans)
print(ans)


ilen = int(input())
flat = [int(a) for a in input().split(' ')]
k = 0
for i in range(1, len(flat) - 1):
	if flat[i] == 0 and flat[i - 1] == 1 and (flat[i + 1] == 1):
		flat[i + 1] = 0
		k += 1
print(k)


n = int(input())
flats = tuple(map(int, input().split()))
count = 0
notquite = []
for i in range(1, n - 1):
	if flats[i] == 0 and flats[i + 1] == 1 and (flats[i - 1] == 1):
		notquite.append(i)
up = len(notquite) - 1
while up >= 0:
	if up < 0:
		up = 1
	if notquite[up - 1] + 2 == notquite[up]:
		count += 1
		up -= 1
	else:
		count += 1
	up -= 1
print(count)


n = int(input())
a = input().split()
s = 0
for (i, e) in enumerate(a[1:n - 1], 1):
	if e == '0' and a[i - 1] == '1' and (a[i + 1] == '1'):
		a[i + 1] = 0
		s += 1
print(s)


Input = lambda : map(int, input().split())
input()
s = input()
s = s.replace(' ', '')
print(s.count('101'))


n = int(input())
a = list(map(int, input().split()))
x = []
c = 0
for i in range(0, n - 2):
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1):
		x.append(i + 1)
p = len(x)
for i in range(0, p):
	if x[i] != '':
		if x[i] + 2 in x:
			c = c + 1
			x[x.index(x[i] + 2)] = ''
		else:
			c = c + 1
print(c)


n = int(input())
a = list(map(int, input().split()))
b = a[:]
k_1 = 0
k_2 = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
		a[i + 1] = 0
		k_1 += 1
	if b[n - 2 - i] == 1 and b[n - i] == 1 and (b[n - 1 - i] == 0):
		b[n - 2 - i] = 0
		k_2 += 1
if k_1 <= k_2:
	print(k_1)
else:
	print(k_2)


n = int(input())
li = list(map(int, input().split()))
m = 0
for i in range(n - 2):
	if li[i] == li[i + 2] == 1 and li[i + 1] == 0:
		m += 1
		li[i + 2] = 0
print(m)


n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
b = []
k = [0] * n
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == a[i + 1] and (a[i + 1] == 1):
		b.append(i)
		k[i] = 1
q = len(b)
for i in range(q - 1):
	if k[b[i]] == 1:
		if abs(b[i] - b[i + 1]) > 2:
			cnt += 1
			k[b[i]] = 0
		else:
			cnt += 1
			k[b[i]] = 0
			k[b[i + 1]] = 0
print(cnt + k.count(1))


n = int(input())
lst = input().split(' ')
m = 0
s = n - 2
for i1 in range(0, s):
	i2 = i1 + 1
	i3 = i1 + 2
	if int(lst[i1]) == 1 and int(lst[i2]) == 0 and (int(lst[i3]) == 1):
		m = m + 1
		lst[i3] = 0
	i1 += 1
print(str(m))


n = int(input())
ar = input().split()
arr = []
ans = 0
for i in range(1, n - 1):
	if ar[i] == '0' and ar[i - 1] == ar[i + 1] and (ar[i - 1] == '1'):
		arr.append(i)
if len(arr) == 1 or len(arr) == 0:
	print(len(arr))
	quit()
i = 0
while i < len(arr):
	try:
		if arr[i + 1] - arr[i] == 2 and i != len(arr) - 1:
			i += 1
	except:
		if arr[i] - arr[i - 1] != 2:
			ans += 1
			break
	ans += 1
	i += 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
k = 0
j = 0
i = 1
while i < n - 1:
	if a[i] == 0:
		if a[i - 1] and a[i + 1]:
			k += 1
			j = i + 1
	i += 1
	a[j] = 0
print(k)


x = int(input())
listik = list(map(int, input().split()))
counter = 0
for i in range(1, x - 1):
	if listik[i] == 0 and listik[i - 1] == 1 and (listik[i + 1] == 1):
		listik[i + 1] = 0
		listik[i - 1] = 0
		counter += 1
print(counter)


N = int(input())
s = [int(x) for x in input().split()]
s = [0, 0, 0, 0, 0] + s + [0, 0, 0, 0, 0]
k = 0
for i in range(N + 5):
	if s[i] == 1 and s[i + 1] == 0 and (s[i + 2] == 1):
		s[i + 2] = 0
		k += 1
print(k)


while True:
	try:
		t = int(input())
	except:
		break
	thelist = list(map(int, input().split()))
	thecount = 0
	for i in range(1, t - 1):
		if thelist[i] == 0 and thelist[i - 1] == 1 and (thelist[i + 1] == 1):
			thelist[i + 1] = 0
			thecount += 1
	print(thecount)


def disturbed_people():
	people = int(input())
	lights = input().split()
	counter = 0
	for i in range(1, len(lights) - 1):
		if int(lights[i]) == 0:
			if int(lights[i - 1]) == 1 and int(lights[i + 1]) == 1:
				lights[i + 1] = 0
				counter += 1
	print(counter)
disturbed_people()


n = int(input())
a = list(map(int, input().split(' ')))
pos = []
res = 0
for i in range(1, n - 1):
	if a[i - 1] == a[i + 1] and a[i + 1] and (not a[i]):
		pos.append(i)
j = 0
while j < len(pos) - 1:
	if pos[j + 1] - pos[j] == 2:
		j += 2
	else:
		j += 1
	res += 1
if j != len(pos):
	res += 1
print(res)


n = int(input())
k = 0
c = 0
a = list(map(int, input().split()))
temp = a.copy()
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
		a[i + 1] = 0
		k += 1
	if temp[i - 1] == 1 and temp[i + 1] == 1 and (temp[i] == 0):
		temp[i - 1] = 0
		c += 1
print(min(k, c))


from collections import Counter

def solution(n, a):
	count = 0
	ind = 1
	while ind < n - 1:
		if a[ind] == 0 and a[ind - 1] == 1 and (a[ind + 1] == 1):
			a[ind + 1] = 0
			ind = 1
			count += 1
		ind += 1
	print(count)

def __starting_point():
	n = [int(val) for val in input().split()][0]
	arr = [int(val) for val in input().split()]
	solution(n, arr)
__starting_point()


from math import ceil
n = int(input())
l = list(map(int, input().split()))
posn = []
la = 1
pho = []
for i in range(1, n - 1):
	if l[i] == 0:
		if l[i - 1] == 1 and l[i + 1] == 1:
			posn.append(i)
posn.sort()
for i in range(1, len(posn)):
	if posn[i] - posn[i - 1] == 2:
		la += 1
	else:
		pho.append(la)
		la = 1
if posn != []:
	pho.append(la)
u = 0
for i in pho:
	u += ceil(i / 2)
print(u)


def disturbed(n, seq):
	index = 1
	off = 0
	while index < n - 1:
		if seq[index] == '0':
			if seq[index - 1] == '1' and seq[index + 1] == '1':
				seq[index + 1] = '0'
				off += 1
		index += 1
	return off
n = int(input())
seq = input().split()
print(disturbed(n, seq))


n = int(input())
Str = input()
print(Str.count('1 0 1'))


n = int(input())
line = input().split()
flats = []
for num in line:
	flats.append(int(num))
ans = 0
for i in range(1, n - 1):
	if flats[i - 1] == 1 and flats[i] == 0 and (flats[i + 1] == 1):
		flats[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
v = [int(x) for x in input().split()]
k = 0
for i in range(1, n - 1):
	if v[i] == 0 and v[i - 1] and v[i + 1]:
		k += 1
		v[i + 1] = 0
print(k)


n = int(input())
a = list(map(int, input().split()))
k = 0
i = 1
while i < n - 1:
	if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
		k += 1
		a[i - 1] = 0
		a[i + 1] = 0
		i += 1
	i += 1
print(k)


n = int(input())
counter = 0
a = [int(x) for x in input().split()]
for i in range(0, n - 2):
	if a[i] == 1 and a[i + 1] == 0 and (a[i + 2] == 1):
		counter += 1
		a[i] = a[i + 2] = 0
print(counter)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(a, b, k) = mints()
	print((a - b) * (k // 2) + (a if k % 2 == 1 else 0))

def count(a):
	i = 0
	r = 0
	while i < len(a):
		if a[i] == 0:
			i += 1
		else:
			r += 1
			if i + 1 < len(a) and a[i + 1] == 1:
				i += 2
			else:
				i += 1
	return r
n = mint()
a = list(mints())
b = []
for i in range(1, len(a) - 1, 2):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		b.append(1)
	else:
		b.append(0)
c = []
for i in range(2, len(a) - 1, 2):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		c.append(1)
	else:
		c.append(0)
print(count(b) + count(c))


def main():
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	count = 0
	for i in range(len(a)):
		if i == 0 or i == len(a) - 1:
			continue
		if a[i] == 0 and a[i - 1] == a[i + 1] == 1:
			a[i + 1] = 0
			count += 1
	print(count)
main()


def Lights(N, flats):
	fl = ' '.join(list(map(str, flats)))
	return fl.count('1 0 1')
N = int(input())
flats = list(map(int, input().strip().split()))[:N]
print(Lights(N, flats))


n = int(input())
p = input().split(' ')
s = ''
for i in range(len(p)):
	s += p[i]
print(s.count('101'))


def solve(size: int, st: list):
	c = 0
	for i in range(size):
		if i - 1 >= 0 and i + 1 < size:
			if str(st[i]) == '0' and str(st[i - 1]) == '1' and (str(st[i + 1]) == '1'):
				st[i - 1] = '0'
				st[i + 1] = '0'
				c += 1
		i += 1
	return c
n = int(input())
val = input().split()
ans = solve(n, val)
print(ans)


n = int(input())
a = []
a[0:n] = map(int, input().split())
ans = 0
if n <= 2:
	print('0')
else:
	for i in range(1, n - 1):
		if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
			a[i + 1] = 0
			ans += 1
	print(ans)


a = int(input())
b = list(input().split())
c = 0
j = 1
while j < a - 1:
	if b[j] == '0' and b[j - 1] == '1' and (b[j + 1] == '1'):
		c += 1
		j += 3
	else:
		j += 1
print(c)


n = int(input())
a_list = [int(a) for a in input().split(' ')]
can_sleep = [None if a_list[0] == 0 else True]
for i in range(1, n - 1):
	if a_list[i] == 0:
		if a_list[i - 1] == 1 and a_list[i + 1] == 1:
			can_sleep.append(False)
		else:
			can_sleep.append(True)
	else:
		can_sleep.append(None)
can_sleep = [(False if a_list[i - 1] == 1 and a_list[i + 1] == 1 else True) if a_list[i] == 0 else None for i in range(1, n - 1)]
can_sleep = [None if a_list[0] == 0 else True] + can_sleep + [None if a_list[0] == 0 else True]
count = 0
for i in range(1, n):
	if i >= 1 and i <= n - 2:
		if can_sleep[i - 1] == False and can_sleep[i] == None and (can_sleep[i + 1] == False):
			can_sleep[i - 1] = True
			can_sleep[i] = True
			can_sleep[i + 1] = True
			count += 1
	if i >= 2 and i <= n - 1:
		j = i - 1
		if can_sleep[j] == False:
			count += 1
print(count)


import math

def lis():
	return list(map(int, input().split()))
x = int(input())
lst = list(map(int, input().split()))
y = 0
for j in range(1, x - 1):
	if lst[j + 1] == 1 and lst[j - 1] == 1 and (lst[j] == 0):
		lst[j + 1] = 0
		y += 1
print(y)


from itertools import count
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1, n - 1):
	if a[i - 1] == a[i + 1] == 1 and a[i] == 0:
		b.append(i)
for i in count():
	if i < len(b) - 1:
		if b[i] + 2 == b[i + 1]:
			del b[i + 1]
	else:
		break
print(len(b))


n = int(input())
tmp = input().split()
arr = []
for i in tmp:
	arr.append(int(i))
i = 0
cnt = 0
sum = 0
while i < n - 2:
	if arr[i] == 1 and arr[i + 1] == 0 and (arr[i + 2] == 1):
		cnt += 1
		i += 2
		if i == n - 1 or i == n - 2:
			if cnt % 2:
				sum += int(cnt / 2) + 1
			else:
				sum += int(cnt / 2)
	else:
		if cnt % 2:
			sum += int(cnt / 2) + 1
		else:
			sum += int(cnt / 2)
		i += 1
		cnt = 0
print(int(sum))


n = int(input())
a = [int(i) for i in input().split()]
i = 1
b = []
while i < n - 1:
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		if len(b) == 0:
			b.append(i + 1)
		else:
			l = len(b)
			if i - 1 != b[l - 1]:
				b.append(i + 1)
	i += 1
print(len(b))


n = int(input()) * 2 - 2
points = input()
count = 0
i = 0
while i + 4 <= n:
	if points[i + 2] == '0':
		if points[i] == '1' and points[i + 4] == '1':
			count += 1
			i += 4
	i += 2
print(count)


import sys
input = sys.stdin.buffer.readline
import os
from math import *
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if arr[i] == 0:
		if arr[i - 1] == 1 and arr[i + 1] == 1:
			arr[i + 1] = 0
			ans += 1
print(ans)


n = int(input())
l = input()
l = ''.join(l.split(' '))
print(len(l.split('101')) - 1)


input()
s = input().replace(' ', '')
k = 0
while '101' in s:
	s = s.replace('101', '100', 1)
	k += 1
print(k)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(mapi())
res = 0
for i in range(n):
	j = 1
	while j < n - 1:
		if a[j] == 0 and a[j + 1] == 1 and (a[j - 1] == 1):
			a[j + 1] = 0
			res += 1
			j += 2
		else:
			j += 1
print(res)


n = int(input())
l = list(map(int, input().split()))
s = set()
for i in range(1, n - 1):
	if l[i - 1] == 1 and l[i + 1] == 1 and (l[i] == 0):
		s.add(i)
s = sorted(s)
ans = 0
i = 0
while len(s) != 0:
	if s[i] + 2 in s:
		s.remove(s[i] + 2)
	del s[i]
	ans += 1
print(ans)


input()
l = ''.join(input().split())
ctr = 0
ans = 0
skip = False
for i in range(len(l) - 2):
	if i >= 2 and (not skip) or i == len(l) - 3:
		if l[i:i + 3] == '101' and l[i - 2:i + 1] != '101':
			ctr = 1
			skip = True
			continue
		elif l[i:i + 3] == '101' and l[i - 2:i + 1] == '101':
			ctr += 1
			skip = True
			continue
		else:
			ans += -(-ctr // 2)
			ctr = 0
	elif i < 2 and (not skip):
		if l[i:i + 3] == '101':
			ctr += 1
			skip = True
			continue
		if i == len(l) - 3:
			ans += ctr
			ctr = 0
	skip = False
print(ans - -ctr // 2)


n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(n):
	if a[i] == 0 and i > 0 and (n > 2) and (i < n - 1):
		if a[i - 1] == 1 and a[i + 1] == 1:
			if n - i - 2 > 0:
				a[i + 1] = 0
				c += 1
			elif n - i - 2 == 0:
				a[i - 1] = 0
				c += 1
if len(a) == 3:
	if a[1] == 0 and a[0] == 1 and (a[2] == 1):
		c += 1
print(c)


n = int(input())
arr = [int(x) for x in input().split()]
count = 0
c = 0
i = 1
while True:
	if i == n - 1:
		break
	if arr[i] == 0:
		if arr[i + 1] == 1 and arr[i - 1] == 1:
			arr[i + 1] = 0
			count += 1
	i += 1
print(count)


import sys
from collections import defaultdict
(line1, line2) = sys.stdin.readlines()
n = int(line1.strip())
a = [int(s) for s in line2.strip().split()]
l = len(a)
k = 0
for i in range(l):
	if i == 0 or i == l - 1 or a[i] != 0:
		continue
	if a[i - 1] == a[i + 1] == 1:
		a[i + 1] = 0
		k += 1
print(k)


def compute_k(flats):
	x = []
	k = 0
	for i in range(len(flats)):
		if i != 0 and i + 1 != len(flats):
			if flats[i] == 0 and flats[i - 1] == 1 and (flats[i + 1] == 1):
				x.append(i)
	k = len(x)
	for i in range(len(x)):
		if i + 1 != len(x):
			if x[i] + 2 == x[i + 1]:
				x[i + 1] -= 1
				k -= 1
	return k
flats_num = int(input())
flats_conditions = input().split(' ')
for i in range(len(flats_conditions)):
	flats_conditions[i] = int(flats_conditions[i])
print(compute_k(flats_conditions))


_ = input()
h = [int(x) for x in input().split()]
acc = 0
i = 1
while i < len(h) - 1:
	if h[i] == 0:
		if h[i - 1] == 1 and h[i + 1] == 1:
			h[i + 1] = 0
			acc += 1
		i += 1
	else:
		i += 1
print(acc)


n_flats = int(input())
lights = [[int(light), False] for light in input().split(' ')]
idx_i = 0
idx_j = 2
n_pair = 0
while idx_j <= n_flats - 1:
	if lights[idx_i][0] == 1 and lights[idx_j][0] == 1 and (lights[idx_i + 1][0] == 0):
		if not lights[idx_i][1] and (not lights[idx_j][1]):
			(lights[idx_i][1], lights[idx_j][1]) = (True, True)
			n_pair += 1
	idx_i += 1
	idx_j += 1
print(n_pair)


numero = int(input())
lista = [int(x) for x in input().split()]
contador = 0
for i in range(1, numero - 1):
	if lista[i - 1] == 1 and lista[i + 1] == 1 and (lista[i] == 0):
		lista[i + 1] = 0
		contador += 1
print(contador)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
ara = inara()
ans = 0
for i in range(1, n - 1):
	if ara[i] == 0 and ara[i - 1] == 1 and (ara[i + 1] == 1):
		ans += 1
		ara[i + 1] = 0
print(ans)


n = int(input())
mas = list(map(int, input().split()))
stroka = ''
for i in mas:
	stroka += str(i)
if '101' not in stroka:
	print(0)
else:
	k = 0
	for i in range(2, len(mas)):
		if mas[i] == 1 and mas[i - 1] == 0 and (mas[i - 2] == 1):
			mas[i] = 0
			k += 1
	print(k)


n = input()
n = int(n)
a = list(map(int, input().split()))
bprv = a[0]
prev = a[1]
curr = a[2]
cnt = 0
for i in range(2, len(a)):
	curr = a[i]
	if curr == 1 and prev == 0 and (bprv == 1):
		cnt += 1
		a[i] = 0
		curr = 0
	bprv = prev
	prev = curr
print(cnt)


o = int(input())
O = 0
p = input().rstrip().split(' ')
for i in range(1, len(p) - 1):
	if p[i] == '0' and p[i - 1] == '1' and (p[i + 1] == '1'):
		p[i + 1] = '0'
		O += 1
print(O)


n = int(input())
a = list(map(int, input().split()))
arr = [0] * n
d = [0] * n
for i in range(1, n - 1):
	if a[i] == 0 and a[i + 1] == 1 and (a[i - 1] == 1):
		d[i] = 1
		arr[i - 1] += 1
		arr[i + 1] += 1
k = 0
for i in range(1, n - 1):
	if d[i]:
		if arr[i - 1] == 2:
			arr[i - 1] = 0
		elif arr[i + 1] == 2:
			arr[i + 1] = 0
		else:
			arr[i + 1] = 0
		if i + 2 < n:
			d[i + 2] = 0
		k = k + 1
		d[i] = 0
print(k)


n = int(input())
l = list(map(str, input().split()))
r = ''.join(l)
t = r.count('101')
print(t)


def main():
	n = int(input())
	arr = [int(x) for x in input().strip().split()]
	ans = 0
	for i in range(2, n):
		if arr[i - 2] == 1 and arr[i - 1] == 0 and (arr[i] == 1):
			arr[i] = 0
			ans += 1
	print(ans)
	return
main()


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


def inint():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def main():
	n = inint()
	a = inlist()
	sol = 0
	for i in range(1, n - 1):
		if a[i] == 0 and a[i - 1] == a[i + 1] == 1:
			sol += 1
			a[i + 1] = 0
	print(sol)
main()


def lights(flats, n):
	k = 0
	for i in range(1, n - 1):
		if flats[i] == 0:
			if flats[i - 1] == 1 and flats[i + 1] == 1:
				flats[i + 1] = 0
				flats[i - 1] = 0
				k += 1
	print(k)
n = int(input())
inp = list(map(int, input().split()))
lights(inp, n)


import math
n = int(input())
b = list(map(int, input().split()))
j = 0
p = 0
while j < n:
	if j < n - 2 and b[j] == 1 and (b[j + 1] == 0) and (b[j + 2] == 1):
		p += 1
		j += 3
	else:
		j += 1
print(p)


n = int(input())
s = input().replace(' ', '')
cnt = 0
while '101' in s:
	s = s.replace('101', '100', 1)
	cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(1, len(l) - 1):
	if l[i - 1] == 1 and l[i + 1] == 1 and (l[i] == 0):
		l[i + 1] = 0
		c += 1
if c != 0:
	print(c)
else:
	print(0)


t = int(input())
a = list(map(str, input().split(' ')))
ans = 0
for i in range(t - 2):
	if a[i] + a[i + 1] + a[i + 2] == '101':
		ans += 1
		a[i + 2] = '0'
print(ans)


n = int(input())
l = list(map(int, input().split()))
arr = [0] * n
for i in range(1, n - 1):
	if l[i - 1] == l[i + 1] == 1 and l[i] == 0:
		arr[i - 1] += 1
		arr[i + 1] += 1
ans = 0
for i in range(1, n - 1):
	if l[i - 1] == l[i + 1] == 1 and l[i] == 0:
		if arr[i - 1] == arr[i + 1] == 1:
			l[i + 1] = 0
		elif arr[i - 1] > arr[i + 1]:
			l[i - 1] = 0
		else:
			l[i + 1] = 0
		ans += 1
print(ans)


n = int(input())
nums = list(map(int, input().split()))

def counter(nums, n):
	if n < 3:
		return 0
	disturbed_index = list()
	for i in range(1, n - 1):
		if nums[i] == 0 and nums[i - 1] == 1 and (nums[i + 1] == 1):
			disturbed_index.append(i)
		if len(disturbed_index) > 1:
			break
	if len(disturbed_index) < 2 and len(disturbed_index) > 0:
		return 1
	if len(disturbed_index) == 0:
		return 0
	if disturbed_index[1] - disturbed_index[0] < 3:
		return 1 + counter(nums[disturbed_index[1] + 1:], len(nums[disturbed_index[1] + 1:]))
	else:
		return 1 + counter(nums[disturbed_index[0] + 1:], len(nums[disturbed_index[0] + 1:]))
print(counter(nums, n))


n = int(input())
s = ''.join(input().split())
s_ = s.split('101')
print((n - len(''.join(s_))) // 3)


def checkNeighbours(seq, index):
	if index - 1 < 0:
		return 0
	if index + 1 >= len(seq):
		return 0
	else:
		if seq[index - 1] is 1 and seq[index] is 0 and seq[index + 1]:
			seq[index + 1] = 0
			return 1
		return 0

def main():
	houses = int(input())
	lights = list(map(int, input().split(' ')))
	k = 0
	for i in range(len(lights)):
		k += checkNeighbours(lights, i)
	print(k)
	return
main()


n = int(input().strip())
arr = list(map(int, input().strip().split()))
c = 0
for i in range(1, n - 1):
	if arr[i - 1] and arr[i + 1] and (not arr[i]):
		arr[i + 1] = 0
		c += 1
print(c)


a = int(input())
b = list(input().split())
k = ''.join(b)
print(k.count('101'))


(l, line, prom) = (int(input()), list(map(int, input().split(' '))), [0] * 100)
for x in range(1, l - 1):
	if not line[x] and line[x - 1] and line[x + 1]:
		(prom[x], prom[x - 1], prom[x + 1]) = (-1, prom[x - 1] + 1, prom[x + 1] + 1)
count = 0
if -1 in prom:
	while 2 in prom:
		(count, i) = (count + 1, prom.index(2))
		prom[i] = 0
		if prom[i - 1] == -1:
			prom[i - 1] = 0
			prom[i - 2] -= 1
		if prom[i + 1] == -1:
			prom[i + 1] = 0
			prom[i + 2] -= 1
	count += len([i for i in prom if i == -1])
print(count)


import sys, math
n = int(sys.stdin.readline())
flat = list(map(int, sys.stdin.readline().split()))
total = 0
for i in range(1, n - 1, 1):
	if flat[i] == 0 and flat[i - 1] == 1 and (flat[i + 1] == 1):
		flat[i + 1] = 0
		total += 1
print(total)


n = int(input())
a = [int(x) for x in input().strip().split(' ')]
k = 0
for i in range(1, n - 1):
	if a[i] == 0:
		if a[i - 1] == 1 and a[i + 1] == 1:
			a[i + 1] = 0
			k += 1
print(k)


import sys
import math
n = int(input())
a = list(map(int, input().split()))
b = []
for j in range(1, n - 1):
	if a[j - 1] == 1 and a[j] == 0 and (a[j + 1] == 1):
		b.append([j - 1, j + 1])
res = 0
if len(b) != 0:
	j = 0
	while j < len(b):
		if j == len(b) - 1:
			res += 1
			break
		elif b[j][1] != b[j + 1][0]:
			res += 1
			j += 1
		else:
			res += 1
			j += 2
print(res)


t = int(input())
y = []
y = [int(k) for k in input().split(' ')]
count = 0
i = 2
while i < len(y):
	if y[i - 2] == 1:
		if y[i - 1] == 0:
			if y[i] == 1:
				count = count + 1
				if i <= len(y) - 3:
					i = i + 2
	i = i + 1
print(count)


n = int(input())
arr = list(map(str, input().split(' ')))
print(''.join(arr).count('101'))


n = int(input(''))
a = list(map(str, input().split()))
s = 0
for i in range(n - 2):
	if a[i] + a[i + 1] + a[i + 2] == '101':
		a[i + 2] = '0'
		s = s + 1
print(s)


n = int(input())
a = list(map(int, input().split()))
r = -1
k = 0
q = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		q += 1
		if i - 1 == r:
			k += 1
			r = -1
			a[i - 1] = 0
		else:
			if r != -1:
				k += 1
			r = i + 1
if r != -1:
	k += 1
print(k)


n = int(input())
setic = set()
s = input().split()
arr = []
for i in range(n):
	arr.append(int(s[i]))
k = 0
perecec = 0
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		if setic.__contains__(i - 1):
			perecec += 1
			arr[i - 1] = 0
		else:
			setic.add(i + 1)
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		k += 1
print(k + perecec)


import math
flat = int(input())
light = list(map(int, input().split()))
candi = []
for (idx, l) in enumerate(light):
	n = []
	if idx > 0 and idx < len(light) - 1:
		if l == 0 and light[idx - 1] == 1 and (light[idx + 1] == 1):
			n.append(idx - 1)
			n.append(idx + 1)
			candi.append(n)
off = []
minim_off = math.inf
for (idx, bulb) in enumerate(candi):
	bulb_a_dup_count = 0
	bulb_b_dup_count = 0
	target_a = bulb[0]
	target_b = bulb[1]
	if target_a in off or target_b in off:
		continue
	for bidx in range(idx + 1, len(candi)):
		if target_a in candi[bidx]:
			bulb_a_dup_count = bulb_a_dup_count + 1
	for bidx in range(idx + 1, len(candi)):
		if target_b in candi[bidx]:
			bulb_b_dup_count = bulb_b_dup_count + 1
	if bulb_a_dup_count > bulb_b_dup_count:
		off.append(target_a)
	else:
		off.append(target_b)
print(len(off))


def solution(house):
	aaah = 0
	for i in range(1, len(house) - 1):
		if house[i] == 0 and house[i - 1] == 1 and (house[i + 1] == 1):
			aaah += 1
			house[i + 1] = 0
	return aaah
tests = [('1 1 0 1 1 0 1 0 1 0', 2), ('1 1 0 0 0', 0), ('1 1 1 1', 0), ('1 0 1 0 1 0 1 0 1', 2)]
for t in tests:
	r = solution(list(map(int, t[0].split())))
	try:
		assert r == t[1]
	except:
		print(t[0])
		print(r)
		exit()
n = int(input())
house = list(map(int, input().split()))
print(solution(house))


count = int(input())
data = [int(x) for x in input().split()]
k = 0

def sleepwell(data):
	global k
	for i in range(1, count - 1):
		if data[i] == 0 and data[i + 1] == 1 and (data[i - 1] == 1):
			data[i + 1] = 0
			k += 1
			sleepwell(data)
sleepwell(data)
print(k)


n = int(input())
houses = list(map(int, input().split()))
hstr = ''.join((str(x) for x in houses))
print(hstr.count('101'))


c = 0
t = int(input())
l = list(map(int, input().split()))
for i in range(1, t - 1):
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		c += 1
		l[i + 1] = 0
print(c)


def main():
	n = int(input())
	A = [int(x) for x in input().strip().split(' ')]
	print(disturbed_people(A))

def disturbed_people(A):
	if 0 not in A[1:-1]:
		return 0
	ans = 0
	for i in range(1, len(A) - 1):
		left = A[i - 1]
		mid = A[i]
		right = A[i + 1]
		if mid == 0 and left == 1 and (right == 1):
			A[i + 1] = 0
			ans += 1
	return ans
main()


n = int(input())
l = list(map(int, input().strip().split(' ')))
i = 1
count = 0
while i < n - 1:
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		l[i + 1] = 0
		i += 2
		count += 1
	else:
		i += 1
print(count)


def read():
	return [int(v) for v in input().split()]

def main():
	n = read()[0]
	a = read()
	cnt = 0
	for i in range(1, n - 1):
		if a[i - 1:i + 2] == [1, 0, 1]:
			a[i + 1] = 0
			cnt += 1
	print(cnt)
main()


n = int(input())
light = input().split()
light = list(map(int, light))
count = 0
for i in range(0, n):
	if light[i:i + 3] == [1, 0, 1] and i + 3 <= n:
		light[i + 2] = 0
		count += 1
print(count)


ka = int(input())
print(input().count('1 0 1'))


t = int(input())
l = list(map(int, input().split()))
s = ''.join(map(str, l))
print(s.count('101'))


n = int(input())
a = list(map(int, input().split()))
disturbed = []
for i in range(n - 2):
	if a[i] == a[i + 2] == 1 and a[i + 1] == 0:
		disturbed.append(i + 1)
tot = 0
a = 0
while a < len(disturbed):
	tot += 1
	if a == len(disturbed) - 1:
		a += 1
	elif disturbed[a + 1] - disturbed[a] == 2:
		a += 2
	else:
		a += 1
print(tot)


n = int(input())
a = [int(x) for x in input().split()]
prev = a[0]
ans = 0

def check(arr):
	prev = arr[:2]
	for a in arr[2:]:
		if prev[0] + a == 2:
			return False
		prev = [prev[1], a]
	return True

def find(arr):
	prev = arr[:4]
	for i in range(4, len(arr)):
		if prev[0] + prev[2] + arr[i] == 3 and prev[1] + prev[3] == 0:
			return i - 2
		prev = prev[1:]
		prev.append(arr[i])
	return -1
ans = 0
while not check(a):
	t = find(a)
	if t == -1:
		prev = a[:2]
		for i in a[2:]:
			if prev[0] + i == 2 and prev[1] == 0:
				ans += 1
			prev = [prev[1], i]
		break
	else:
		ans += 1
		a[t] = 0
print(ans)


_ = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(1, len(a) - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		a[i + 1] = 0
		res += 1
print(res)


n = int(input())
a = [int(i) for i in input().split()]
s = ''
for item in a:
	s += str(item)
print(s.count('101'))


n = int(input())
l = list(map(int, input().split()))
ans = 0
for f in range(1, n - 1):
	if l[f] == 0 and l[f - 1] == 1 and (l[f + 1] == 1):
		ans += 1
		l[f + 1] = 0
print(ans)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	correct = False
	k = 0
	while correct == False:
		hasOne = False
		for (index, i) in enumerate(a):
			left = index - 1
			right = index + 1
			if left >= 0 and right < n:
				if a[left] == 1 and i == 0 and (a[right] == 1):
					hasOne = True
					a[right] = 0
					k += 1
					break
		if hasOne == False:
			correct = True
	print(k)
main()


import sys
n = int(input())
s = list(map(int, input().split()))
disturb = []
for i in range(1, n - 1):
	if s[i - 1] and s[i + 1] and (not s[i]):
		disturb.append(i)
if len(disturb) == 0:
	print(0)
	sys.exit(0)
count = 0
while len(disturb) > 0:
	if len(disturb) == 1:
		count += 1
		break
	if disturb[0] + 2 == disturb[1]:
		disturb.pop(0)
		disturb.pop(0)
		count += 1
	else:
		disturb.pop(0)
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
s = 0
one = set([-1, -1])
for i in range(1, n - 1):
	if a[i] == 0:
		if a[i - 1] == 1 and a[i + 1] == 1:
			two = set([i - 1, i + 1])
			if two & one:
				pass
			else:
				s += 1
				one = two
	else:
		pass
print(s)


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
idx = 0
cnt = 0
while idx < n - 2:
	if arr[idx:idx + 3] == [1, 0, 1]:
		cnt += 1
		idx += 3
	else:
		idx += 1
print(cnt)


n = int(input())
h = input().split(' ')
v = [0 for i in range(n)]
for i in range(n):
	h[i] = int(h[i])
for i in range(n):
	if i >= 2:
		if h[i - 2] == 1 and h[i - 1] == 0 and (h[i] == 1):
			v[i] = 1
cnt = 0
for i in range(n):
	if v[i] == 1:
		cnt += 1
		if i + 2 < n:
			v[i + 2] = 0
print(cnt)


n = int(input())
lights = [int(v) for v in input().split()]
elements = set()
for (i, val) in enumerate(lights):
	if 0 < i < n - 1 and (not val):
		prev = i - 1
		nex = i + 1
		if lights[prev] and lights[nex] and (prev not in elements) and (nex not in elements):
			elements.add(nex)
print(len(elements))


from math import ceil, sqrt, floor
import sys
n = int(input())
tab = list(map(int, input().split()))
tt = 0
for i in range(1, n - 1):
	if not tab[i] and tab[i - 1] == tab[i + 1] == 1:
		tab[i + 1] = 0
		tt += 1
print(tt)


n = int(input())
xs = list(map(int, input().split()))
res = 0
for i in range(1, n - 1):
	if (xs[i - 1], xs[i], xs[i + 1]) == (1, 0, 1):
		res += 1
		xs[i + 1] = 0
print(res)


t = int(input())
lista = [int(x) for x in input().split()]
ans = 0
for x in range(t):
	if x > 0 and x < t - 1:
		if lista[x] == 0 and lista[x - 1] == 1 and (lista[x + 1] == 1):
			lista[x + 1] = 0
			ans += 1
print(ans)


n = int(input())
arr = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	if i == 0 or i == n - 1:
		print(end='')
	elif arr[i - 1] == 1 and arr[i + 1] == 1 and (arr[i] == 0):
		arr[i + 1] = 0
		ans += 1
print(ans)


import sys
n = int(input())
flats = [int(i) for i in input().split()]
dist = []
dual = 0
for i in range(1, n - 1):
	if flats[i - 1] == 1 and flats[i] == 0 and (flats[i + 1] == 1):
		dist.append(i)
last = 0
for j in range(0, len(dist) - 1):
	if dist[j + 1] - dist[j] == 2 and last == 0:
		dual += 1
		last = 1
	else:
		last = 0
print(len(dist) - dual)


def is_disturbed(flat):
	if flat == 0 or flat == n - 1:
		return False
	return a[flat] == 0 and a[flat - 1] == 1 == a[flat + 1]
n = int(input())
a = list(map(int, input().split()))
disturbed = False
off = 0
for i in range(1, n):
	if a[i] == 1:
		if disturbed:
			off += 1
			a[i] = 0
			disturbed = False
	elif is_disturbed(i):
		disturbed = True
print(off)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('YES')
nn = lambda : print('NO')
from math import log10, log2, ceil, factorial as fac, gcd, inf, sqrt, log
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter
mod = 10 ** 9 + 7

def f():
	n = t()
	s = ''.join(ss().split())
	print(s.count('101'))
f()


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		i = 0
		count = 0
		while i < n - 2:
			if l[i] == 1 and l[i + 1] == 0 and (l[i + 2] == 1):
				count += 1
				i += 3
			else:
				i += 1
		print(count)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


N = int(input())
a = list(map(int, input().split()))
dis = 0
for i in range(1, len(a) - 1):
	if a[i] - a[i - 1] == -1 and a[i + 1] - a[i] == 1:
		a[i + 1] = 0
		dis += 1
print(dis)


n = int(input())
a = list(map(int, input().split()))
was = [False] * n
ans = 0
worried = [False] * n
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		worried[i] = True
for i in range(1, n - 1):
	if not was[i] and worried[i]:
		if i < n - 3 and (not was[i + 2]) and worried[i]:
			was[i + 2] = True
		was[i] = True
		ans += 1
print(ans)


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	c = 0
	i = 0
	while i < n:
		if l[i] == 1:
			if i + 2 < n:
				if l[i + 1] == 0 and l[i + 2] == 1:
					c += 1
					i += 3
				else:
					i += 1
			else:
				i += 1
		else:
			i += 1
	pr(c)
for _ in range(1):
	solve()


n = int(input())
L = list(map(int, input().split()))
cont = 0
k = 0
while k < n - 2:
	if L[k] == L[k + 2] == 1 and L[k + 1] == 0:
		cont += 1
		k += 3
	else:
		k += 1
print(cont)


n = int(input())
a = [int(x) for x in input().split()]
overlapping = 0
bad = 0
if n >= 5:
	for i in range(2, n - 2):
		if a[i - 2] == 1 and a[i - 1] == 0 and (a[i] == 1) and (a[i + 1] == 0) and (a[i + 2] == 1):
			overlapping += 1
			a[i] = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		bad += 1
		a[i + 1] = 0
print(overlapping + bad)


n = int(input())
a = list(map(int, input().split()))
i = 0
count = 0
while i < n:
	if i == 0:
		pass
	elif i >= n - 1:
		break
	elif a[i] == 0:
		if a[i + 1] == 1 and a[i - 1] == 1:
			a[i + 1] = 0
			count += 1
	i += 1
print(count)


x = input()
flats = input()
flats = flats.replace(' ', '')
counter = 0
while '101' in flats:
	flats = flats.replace('101', '100', 1)
	counter += 1
print(counter)


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
ans = 0
for k in range(1, n - 1):
	if l[k] == 0 and l[k - 1] == 1 and (l[k + 1] == 1):
		l[k + 1] = 0
		ans += 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
c = 0
i = 1
while i < len(a) - 1:
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		i = i + 3
		c = c + 1
	else:
		i = i + 1
print(c)


n = int(input())
a = [int(i) for i in input().split()]
z = []
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		z.append(i)
i = 0
while i < len(z) - 1:
	if z[i] == z[i + 1] - 2:
		z[i] = z[i] + 1
		z.pop(i + 1)
	else:
		i += 1
print(len(z))


n = int(input())
a = list(map(int, input().split()))
(c1, c2) = (0, 0)
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		c1 += 1
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i] == 0 and (a[i + 1] == 1):
		c2 += 1
		a[i + 1] = 0
print(min(c1, c2))


input()
state = ''.join(input().split())
print(state.count('101'))


n = int(input())
ary = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if ary[i] != 0:
		continue
	if ary[i - 1] == 1 and ary[i + 1] == 1:
		ary[i + 1] = 0
		ans += 1
print(ans)


def isdist(li, ind):
	return li[ind] == li[ind + 2] and li[ind] == 1 and (li[ind + 1] == 0)
n = int(input())
lals = list(map(int, input().split()))
rals = list(reversed(lals))
rl = 0
tl = 0
for i in range(n - 2):
	if isdist(lals, i):
		lals[i + 2] = 0
		tl += 1
	if rals[i] == rals[i + 2] and rals[i] == 1 and (rals[i + 1] == 0):
		rals[i + 2] = 0
		rl += 1
print(min(rl, tl))


n = int(input())
a = list(map(int, input().split()))
p = 0
for i in range(n - 2):
	if a[i] == a[i + 2] == 1 != a[i + 1]:
		a[i + 2] = 0
		p += 1
print(p)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	r = 0
	for i in range(1, n - 1):
		if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
			r += 1
			a[i + 1] = 0
	return r
print(main())


n = int(input())
salas = [int(i) for i in input().split()]
incomodados = []
for i in range(1, n - 1):
	if salas[i] == 0 and salas[i - 1] == 1 and (salas[i + 1] == 1):
		incomodados.append(i)
k = 0
i = 0
while i <= len(incomodados) - 1:
	if incomodados[i] + 2 in incomodados:
		k += 1
		i += 2
	else:
		k += 1
		i += 1
print(k)


gcd = lambda a, b: gcd(b, a % b) if b else a

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ind = []
	for i in range(1, len(arr) - 1):
		if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
			ind.append(i)
	total = 0
	i = 0
	while i < len(ind):
		if i + 1 < len(ind) and ind[i] == ind[i + 1] - 2:
			i += 2
		else:
			i += 1
		total += 1
	print(total)
main()


def main():
	n = int(input())
	vec = list(map(int, input().split()))
	i = 0
	k = 0
	while i + 2 < n:
		if vec[i] == 1 and vec[i + 1] == 0 and (vec[i + 2] == 1):
			vec[i + 2] = 0
			k += 1
		i += 1
	print(k)
main()


a = int(input())
b = input()
b = b.split(' ')
c = []
for i in b:
	c.append(int(i))
s = 0
for i in range(1, len(c) - 1):
	if c[i] == 0 and c[i - 1] == 1 and (c[i + 1] == 1):
		c[i + 1] = 0
		s = s + 1
print(s)


n = int(input())
k = 0
s = input()
s = s.split(' ')
for i in range(n - 2):
	if s[i] == '1':
		if s[i + 1] == '0':
			if s[i + 2] == '1':
				k += 1
				s[i + 2] = '0'
print(k)


import sys
import collections
inp = sys.stdin
n = int(inp.readline())
lst = list(map(int, inp.readline().split()))
cnt = 0
for i in range(1, n - 1):
	if lst[i + 1] == 1 and lst[i - 1] == 1 and (lst[i] == 0):
		lst[i + 1] = 0
		cnt = cnt + 1
print(cnt)


import math
num = int(input())
arr = input()
arr = list(arr)
arr = [int(i) for i in arr if i != ' ']
min = 0
dbl = 0
zer = 0
one = 0
for i in range(num - 2):
	if arr[i] == 1:
		if arr[i + 1] == 0:
			if arr[i + 2] == 1:
				dbl += 1
				zer += 1
				min += 1
				if dbl == 2:
					min -= 1
					dbl = 0
		else:
			dbl = 0
	elif zer == 1:
		zer = 0
	else:
		dbl = 0
print(min)


n = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.insert(n + 1, 0)
ans = 0
for i in range(1, n + 1):
	if A[i] == 0:
		if A[i - 1] == 1 and A[i + 1] == 1:
			A[i + 1] = 0
			ans += 1
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
ind = []
i = 1
c = 0
k = 0
cc = 0
while i < n - 1:
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		ind.append([i, 0])
	i += 1
if len(ind) == 0:
	print(0)
	exit()
i = 0
for i in range(len(ind) - 1):
	if abs(ind[i][0] - ind[i + 1][0]) == 2 and ind[i][1] != 1:
		ind[i][1] = 1
		ind[i + 1][1] = 1
		c += 1
	elif ind[i][1] == 0:
		c += 1
		ind[i][1] = 1
if ind[len(ind) - 1][1] == 0:
	c += 1
print(c)


n = int(input())
A = list(map(int, input().split()))
pos = ['woi']
i = 1
count = 0
prev = -1
temp = 0
while i < n - 1:
	if A[i - 1] and A[i + 1] and (A[i] == 0):
		if prev + 2 == i:
			temp += 1
		else:
			temp = 1
		prev = i
		i += 1
	else:
		count += (temp + 1) // 2
		temp = 0
	i += 1
count += (temp + 1) // 2
print(count)


from sys import stdin, stdout
int(stdin.readline())
stdout.write(str(''.join(stdin.readline().split()).count('101')))


n = int(input())
l = [int(i) for i in input().split()]
s = ''.join((str(i) for i in l))
print(s.count('101'))


n = int(input())
m = list(map(int, input().split()))
is_disturbed = [0 < i < n - 1 and m[i - 1] == m[i + 1] == 1 and (m[i] == 0) for i in range(n)]
c = 0
while any(is_disturbed):
	happened = False
	for i in range(1, n - 1):
		if is_disturbed[i - 1] and is_disturbed[i + 1]:
			m[i] = 0
			is_disturbed[i - 1] = is_disturbed[i + 1] = False
			happened = True
			break
	if not happened:
		for i in range(0, n - 1):
			if is_disturbed[i + 1]:
				m[i] = 0
				is_disturbed[i + 1] = False
				break
	c += 1
print(c)


n = int(input())
arr = input().strip().split()
st = ''.join(arr)
k = 0
while st.find('10101') != -1:
	st = st.replace('10101', '10001', 1)
	k += 1
while st.find('101') != -1:
	st = st.replace('101', '100', 1)
	k += 1
print(k)


from sys import stdin, stdout
n = int(stdin.readline())
ar = list(map(int, stdin.readline().strip().split()))
cnt = 0
for i in range(1, n - 1):
	if ar[i - 1] == ar[i + 1] and ar[i] == 0 and (ar[i - 1] == 1):
		ar[i + 1] = 0
		cnt += 1
print(cnt)


n = int(input())
a = list(map(int, input().split()))
y = 1
s = 0
while y < len(a) - 1:
	if a[y] == 0 and a[y - 1] == 1 and (a[y + 1] == 1):
		a[y - 1] = 0
		a[y + 1] = 0
		s += 1
	y += 1
print(s)


a = int(input().strip())
arr = list(map(int, input().strip().split()))
ans = 0
for i in range(1, a - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i - 1] == arr[i + 1]):
		arr[i + 1] = 0
		ans += 1
print(ans)


a = int(input())
strIn = ''.join(input().split())
countx = 0
for _loop in range(a):
	idx = strIn.find('101')
	if idx == -1:
		break
	if idx + 3 >= len(strIn):
		countx += 1
		break
	strIn = strIn[:idx + 2] + '0' + strIn[idx + 3:]
	countx += 1
print('{}'.format(countx))


import re
n = int(input())
arr = list(map(int, input().strip().split()))
ans = 0
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		ans += 1
		arr[i + 1] = 0
print(ans)


n = int(input())
pa = input()
p = pa.split()
for i in range(0, len(p)):
	p[i] = int(p[i])
ls = list()
ans = 0
for i in range(1, len(p) - 1):
	if p[i] == 0 and p[i - 1] == 1 and (p[i + 1] == 1):
		ans += 1
		p[i + 1] = 0
print(ans)


n = int(input())
l = list(map(int, input().split(' ')))
l1 = list()
for i in range(1, n - 1):
	if l[i - 1] and l[i + 1] and (not l[i]):
		l1.append(i)
if l1:
	s = 0
	while 1:
		try:
			if l1[1] - l1[0] == 2:
				s += 1
				l1.pop(0)
				l1.pop(0)
			else:
				s += 1
				l1.pop(0)
		except:
			break
	if len(l1):
		s += 1
	print(s)
else:
	print(0)


def solve():
	N = int(input())
	A = [int(k) for k in input().split()]
	res = 0
	for i in range(1, N - 1):
		if A[i] == 0 and A[i - 1] == A[i + 1] == 1:
			A[i + 1] = 0
			res += 1
	print(res)
solve()


n = int(input())
a = list(map(int, input().rstrip().split()))
count = 0
for i in range(1, n - 1):
	if a[i - 1] == 1 and a[i + 1] == 1 and (a[i] == 0):
		a[i + 1] = 0
		count += 1
print(count)


n = int(input())
arr = list(map(int, input().split()))
arr.insert(0, 0)
arr.append(0)
n = len(arr)
res = 0
for i in range(1, n - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		arr[i + 1] = 0
		res += 1
print(res)


n = int(input())
q = list(map(int, input().rstrip().split()))
disturbed = []
for i in range(1, n - 1):
	if q[i] == 0 and q[i + 1] == 1 and (q[i - 1] == 1):
		disturbed.append(i)
removed = 0
i = 0
while i < len(disturbed) - 1:
	if disturbed[i] == disturbed[i + 1] - 2:
		removed = removed + 1
		disturbed.pop(i)
		disturbed.pop(i)
	else:
		i = i + 1
removed = removed + len(disturbed)
print(removed)


from sys import stdin, stdout
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
map = {}
c = j = i = 0
if n == 3:
	if arr[0] == 1 and arr[1] == 0 and (arr[2] == 1):
		ans = 1
	else:
		ans = 0
else:
	while i <= len(arr) - 3:
		if arr[i] == 1 and arr[i + 1] == 0 and (arr[i + 2] == 1):
			try:
				map[j] += 1
			except:
				map[j] = 1
			i += 1
		else:
			j += 1
		i += 1
	ans = 0
	for (k, v) in map.items():
		if v >= 2:
			if v % 2 == 0:
				ans += v // 2
			else:
				ans += v // 2 + 1
		else:
			ans += 1
stdout.write(str(ans) + '\n')


n = int(input())
A = list(map(int, input().split()))
cnt = 0
for (i, j, k) in zip(range(n - 2), range(1, n - 1), range(2, n)):
	if (A[i], A[j], A[k]) == (1, 0, 1):
		cnt += 1
		A[k] = 0
print(cnt)


flats = int(input())
flatstates = input().split()
for i in range(len(flatstates)):
	flatstates[i] = int(flatstates[i])
count = 0
for i in range(1, len(flatstates) - 1):
	if flatstates[i - 1] == 1 and flatstates[i + 1] == 1 and (flatstates[i] == 0):
		flatstates[i + 1] = 0
		count += 1
print(count)


flats_number = int(input())
light_state_list = [int(a) for a in input().split(' ')]
turn_off = 0
for i in range(1, flats_number - 1):
	if light_state_list[i] == 0 and light_state_list[i - 1] == 1 and (light_state_list[i + 1] == 1):
		light_state_list[i + 1] = 0
		turn_off += 1
print(turn_off)


def getInts():
	return [int(n) for n in input().split()]
n = int(input())
A = getInts()
S = set()
count = 0
for i in range(1, n - 1):
	if A[i - 1] == 1 and A[i] == 0 and (A[i + 1] == 1):
		if i + 1 not in S and i - 1 not in S:
			S.add(i + 1)
			count += 1
print(count)


n = int(input())
l = list(map(int, input().split()))
dis = [0 for i in range(n)]
for i in range(1, n - 1):
	if l[i - 1] + l[i + 1] == 2 and l[i] == 0:
		dis[i] = 1
k = sum(dis)
for i in range(1, n - 1):
	if dis[i - 1] + dis[i + 1] == 2:
		k -= 1
		dis[i + 1] = 0
print(k)


from sys import stdin

def find_disturbed(n, arr):
	index = []
	for i in range(1, n - 1):
		try:
			if arr[i] == 0:
				if arr[i - 1] == 1 and arr[i + 1] == 1:
					index.append(i)
		except:
			pass
	return index
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
index = find_disturbed(n, arr)
count = 0
i = 0
while i < len(index):
	if i == len(index) - 1:
		count += 1
		break
	if index[i] + 2 == index[i + 1]:
		count += 1
		i += 2
	else:
		count += 1
		i += 1
print(count)


numHouses = input()
block = input()
print(block.count('1 0 1'))


n = int(input())
arr = list(map(int, input().split()))
ans = 0
ind = 1
while ind < n - 1:
	if arr[ind] == 0 and arr[ind - 1] == 1 and (arr[ind + 1] == 1):
		ans += 1
		arr[ind + 1] = 0
		ind += 1
	ind += 1
print(ans)


n = input()
tab = list(map(int, input().split()))
count = 0
for i in range(len(tab)):
	if i >= 2:
		if tab[i - 2] == 1 and tab[i - 1] == 0 and (tab[i] == 1):
			count = count + 1
			tab[i] = 0
print(count)


n = int(input())
l = list(map(int, input().split()))
t = 0
for i in range(1, n - 1):
	j = i - 1
	k = i + 1
	if l[i] == 0:
		if l[j] == 1 and l[k] == 1:
			l[k] = 0
			t += 1
print(t)


n = int(input())
arr = list(map(int, input().split()))
flag1 = 0
ans = 0
i = 0
while i < n - 1:
	if arr[i] == 1 and arr[i + 1] == 0:
		if i < n - 2 and arr[i + 2] == 1:
			ans += 1
			i += 2
	i += 1
print(ans)


import math as m
t = int(input())
flats = list(map(int, input().split()))
ans = 0
for i in range(t):
	if i > 0 and i < t - 1 and (flats[i] == 0):
		if flats[i - 1] == 1 and flats[i + 1] == 1:
			flats[i + 1] = 0
			ans += 1
print(ans)


n = int(input())
arr = list(input().split())
dist = []
for i in range(1, n - 1):
	if arr[i] == '0' and arr[i - 1] == '1' and (arr[i + 1] == '1'):
		dist.append(i)
j = 0
ans = 0
while j < len(dist) - 1:
	if dist[j] + 2 == dist[j + 1]:
		j += 2
	else:
		j += 1
	ans += 1
if j == len(dist) - 1:
	ans += 1
print(ans)


n = int(input())
arr = list(map(int, input().split()))
markings = arr[:]
count = 0
for i in range(1, n - 1):
	if arr[i] == 0:
		if markings[i - 1] == 1 and markings[i + 1] == 1:
			markings[i + 1] = 0
			count += 1
print(count)


n = int(input())
a = list((int(i) for i in input().split(' ')))
k = 0
prev = -1
for i in range(n):
	if i > 0 and i < n - 1 and (a[i - 1] == 1) and (a[i + 1] == 1) and (a[i] == 0):
		if prev > 0 and prev == i - 2:
			prev = -1
		else:
			k += 1
			prev = i
print(k)


N = int(input())
x = list(map(int, input().split()))
ans = 0
for k in range(1, len(x) - 1):
	if x[k - 1] == 1 and x[k + 1] == 1 and (x[k] == 0):
		x[k + 1] = 0
		ans += 1
print(ans)


n = int(input())
a = [int(_) for _ in input().split()]
p = 0
for i in range(1, n - 1):
	if a[i - 1] == a[i + 1] == 1 and a[i] == 0:
		p += 1
		a[i + 1] = 0
print(p)


n = int(input())
numb = list(map(int, input().split()))
ans = 0
for i in range(1, len(numb) - 1):
	if numb[i] == 0 and numb[i - 1] == 1 and (numb[i + 1] == 1):
		ans += 1
		numb[i + 1] = 0
print(ans)


n = int(input())
a = [int(e) for e in input().split()]
ans = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		ans += 1
		a[i + 1] = 0
print(ans)


n = int(input())
arr = [0] + list(map(int, input().split())) + [0]
ct = 0
for i in range(1, len(arr) - 1):
	if arr[i] == 0 and arr[i - 1] == 1 and (arr[i + 1] == 1):
		arr[i + 1] = 0
		ct += 1
print(ct)


n = int(input())
a = list(map(int, input().split()))
i = 0
count = 0
while i < len(a):
	if a[i:i + 3] == [1, 0, 1]:
		count += 1
		i += 2
	i += 1
print(count)


def worried_tenants(flats_num, flats):
	path = []
	c = 0
	i = len(flats) - 1
	while i >= 2:
		if flats[i] == '1':
			if i - 2 >= 0 and flats[i] == flats[i - 2] and (flats[i] != flats[i - 1]):
				if i >= 4 and flats[i - 2] == flats[i - 4]:
					i -= 4
				else:
					i -= 2
				c += 1
			else:
				i -= 1
		else:
			i -= 1
	return c
flats = input()
tennants = input().split()
answer = worried_tenants(flats, tennants)
print(answer)


n = int(input())
homes = list(map(int, input().split(' ')))
new = homes.copy()
for i in range(1, n - 1):
	if homes[i - 1] == 1 and homes[i + 1] == 1 and (homes[i] == 0):
		new[i] = 'wor'
		new[i - 1] = 'dist'
		new[i + 1] = 'dist'
cnt = 0
for i in range(1, n - 1):
	if new[i] == 'wor':
		if new[i - 1] == 'del' or new[i + 1] == 'del':
			continue
		else:
			new[i + 1] = 'del'
for item in new:
	if item == 'del':
		cnt += 1
print(cnt)


n = int(input())
a = list(map(int, input().split()))
d = [0] * n
for i in range(1, n):
	if 0 < i < n - 1 and a[i - 1] == a[i + 1] == 1 and (a[i] == 0):
		d[i - 1] += 1
		d[i + 1] += 1
k = 0
ok = sum(d) == 0
while not ok:
	m = max(d)
	for i in range(n):
		ok = True
		for j in range(n):
			if 0 < j < n - 1 and a[j - 1] == a[j + 1] == 1 and (a[j] == 0):
				ok = False
				break
		if ok:
			break
		if d[i] == m:
			d[i] = 0
			if a[i + 1] == 0:
				d[i + 2] -= 1
			if a[i - 1] == 0:
				d[i - 2] -= 1
			a[i] = 0
			k += 1
print(k)


import sys

def inpt():
	return sys.stdin.readline().strip()
n = int(inpt())
print(max(0, inpt().count('1 0 1')))


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
ans = 0
for i in range(1, n - 1):
	if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
		ans += 1
		a[i + 1] = 0
print(ans)


i = 0
s = 0
x = int(input())
a = [int(i) for i in input().split()]
for i in range(1, x - 1):
	if not a[i] and a[i + 1] and a[i - 1]:
		s += 1
		a[i + 1] = 0
print(s)


(n, a, k) = (int(input()), list(map(int, input().split())), 0)
for i in range(1, n - 1):
	if a[i] == 0:
		if a[i - 1] == a[i + 1] == 1:
			k += 1
			a[i + 1] = 0
print(k)


k = int(input())
home = input().split()
ans = 0
for i in range(0, k):
	if home[i] == '0':
		if 0 < i and i < k - 1:
			if home[i - 1] == '1' and home[i + 1] == '1':
				home[i + 1] = '0'
				ans += 1
print(ans)


q = int(input())
houses = list(map(int, input().split(' ')))
count = 0
for i in range(1, q - 1):
	if not houses[i] and houses[i - 1] and houses[i + 1]:
		houses[i + 1] = 0
		count += 1
print(count)


n = int(input())
s = input()
s = s.replace(' ', '')
k = 0
li = [0] * len(s)
for i in range(len(s) - 2):
	if s[i:i + 3] == '101':
		li[i + 2] += 1
		li[i] += 1
		k += 1
o = 0
m = 2
while k > 0:
	if li.count(2) == 0:
		m = 1
	g = li.index(m)
	(li[g], li[g - 2], li[g + 2]) = (0, li[g - 2] - 1, li[g + 2] - 1)
	o += 1
	k -= m
print(o)


n = int(input())
a = list(map(int, input().split()))
co = 0
for i in range(1, len(a) - 1):
	if i >= 1 and i <= len(a) - 4 and (a[i] == 0) and (a[i - 1] == a[i + 1] == 1) and (a[i + 2] == 0) and (a[i + 3] == 1):
		co += 1
		a[i + 1] = 0
	elif a[i - 1] == a[i + 1] == 1 and a[i] == 0:
		co += 1
		a[i + 1] = 0
print(co)


inputVa = input()
z = input()
a = z.split(' ')
ans = 0
for i in range(len(a) - 2):
	if a[i] == '1' and a[i + 1] == '0' and (a[i + 2] == '1'):
		a[i + 2] = 0
		ans = ans + 1
print(ans)


c = int(input())
o = 0
a = [0] + [int(z) for z in input().split()] + [0]
for i in range(1, c + 1):
	if a[i] == 0 and a[i - 1] * a[i + 1]:
		a[i + 1] = 0
		o += 1
print(o)


t = int(input())
arr = list(map(int, input().split()))
if t > 2:
	check = [1, 0, 1]
	count = 0
	for i in range(0, t - 2):
		if arr[0 + i:3 + i] == check:
			arr[3 + i - 1] = 0
			count = count + 1
	print(count)
else:
	print(0)


n = int(input())
ar = list(map(int, input().split()))
t = []
for i in range(n - 2):
	lights = ar[i:i + 3]
	if lights == [1, 0, 1]:
		t.append(i + 1)
count = 0
l = len(t)
while l > 0:
	if l == 1:
		count += 1
		break
	if t[0] == t[1] - 2:
		t.pop(0)
		t.pop(0)
		count += 1
		l -= 2
	else:
		t.pop(0)
		count += 1
		l -= 1
print(count)


n = int(input())
o = input()
print(o.count('1 0 1'))


(n,) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 0
for i in range(2, n):
	if l[i - 2] and (not l[i - 1]) and l[i]:
		ans += 1
		l[i] = False
print(ans)


def Disturbed(n, arr):
	count = 0
	i = 1
	while i < n - 1:
		if arr[i] == 0:
			if arr[i - 1] == 1 and arr[i + 1] == 1:
				arr[i + 1] = 0
				count += 1
				i += 2
		i += 1
	print(count)
n = int(input())
arr = list(map(int, input().split()))
Disturbed(n, arr)


def main():
	n = int(input())
	rd = lambda : list(map(int, input().split()))
	arr = rd()
	cnt = 0
	for (i, val) in enumerate(arr):
		if i < n - 1 and i > 0 and (val == 0) and (arr[i + 1] == arr[i - 1]) and (arr[i - 1] == 1):
			arr[i + 1] = 0
			cnt += 1
	print(cnt)
main()


a = int(input())
l = ''.join(input().split())
print(l.count('101'))


n = int(input())
h = list(map(int, input().split()))
di = []
for i in range(1, n - 1):
	if h[i] == 0 and h[i - 1] == h[i + 1] == 1:
		di.append(i)
guan = 0
while len(di) > 0:
	if len(di) > 1:
		if di[0] == di[1] - 2:
			di.remove(di[0])
			di.remove(di[0])
			guan += 1
		else:
			di.remove(di[0])
			guan += 1
	else:
		di.remove(di[0])
		guan += 1
print(guan)


input()
X = list(map(int, input().split()))
Count = 0
for i in range(1, len(X) - 1):
	if X[i] == 0 and X[i - 1] == 1 and (X[i + 1] == 1):
		X[i + 1] = 0
		Count += 1
print(Count)


def disturbed(a):
	c = 0
	if len(a) == 3:
		for i in range(1, len(a) - 1):
			if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
				c += 1
				print(c)
				return
	for i in range(1, len(a) - 1):
		if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
			(a[i - 1], a[i + 1]) = (0, 0)
			c += 1
	print(c)
	return
n = int(input())
a = list(map(int, input().split()))
disturbed(a)


n = int(input())
f = list(map(int, input().split()))
off_count = 0
for i in range(1, n - 1):
	if f[i - 1] == f[i + 1] == 1 and f[i] == 0:
		f[i + 1] = 0
		off_count += 1
print(off_count)


a = int(input())
b = input().split()
b = [int(i) for i in b]
record = []
for i in range(1, len(b) - 1):
	if b[i - 1] == 1 and b[i + 1] == 1 and (b[i] == 0):
		record.append(i)
if len(record) > 0:
	temp = record[0]
	out = 1
	init = True
	for i in record[1:]:
		if i == temp + 2:
			temp = i
			if init == True:
				init = False
			else:
				init = True
				out += 1
		else:
			init = True
			temp = i
			out += 1
	print(out)
else:
	print(0)


input()
a = map(int, input().split())

def sweet(it):
	it = iter(it)
	x = 0
	for q in it:
		if x % 2 != q:
			x += 1
		else:
			if x >= 3:
				yield ((x - 1) // 2)
			x = q
	if x >= 3:
		yield ((x - 1) // 2)

def dose(x):
	return (x - 1) // 2 + 1
print(sum(map(dose, sweet(a))))


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
bb = [0 < i < n - 1 and a[i] == 0 and (a[i - 1] == a[i + 1] == 1) for i in range(n)]
flex = [True for _ in range(n)]
cnt = 0
for i in range(1, n - 1):
	if bb[i]:
		if i - 2 > 0 and bb[i - 2] and flex[i - 2]:
			flex[i] = False
		else:
			cnt += 1
sys.stdout.write(str(cnt))


n = int(input())
ar = list(map(int, input().split()))

def check(x, ar):
	if 0 < x < len(ar) - 1:
		if ar[x - 1] == 1 == ar[x + 1] > ar[x]:
			return x
		return 0
	return 0

def find(ar):
	for x in range(1, len(ar) - 1):
		if check(x, ar):
			return x
	return 0
q = find(ar)
res = 0
while q:
	if check(q - 2, ar):
		ar[q - 1] = 0
		res += 1
		q = find(ar)
		continue
	if check(q + 2, ar):
		ar[q + 1] = 0
		res += 1
		q = find(ar)
		continue
	ar[q - 1] = 0
	res += 1
	q = find(ar)
print(res)


n = int(input())
m = input().split()
m = ''.join(m)
print(m.count('101'))


n = int(input())
lis = list(map(int, input().split()))
cou = 0
for i in range(1, n - 1):
	if lis[i] == 0 and lis[i - 1] == 1 and (lis[i + 1] == 1):
		cou += 1
		lis[i + 1] = 0
print(cou)


n = int(input())
s = input().split()
s = list(s)
c = 0
for i in range(1, n - 1):
	if s[i - 1] == '1' and s[i] == '0' and (s[i + 1] == '1'):
		c += 1
		s[i + 1] = 0
print(c)


n = int(input())
x = input()
xx = x.split()
g = 0
for i in range(1, n - 1):
	if xx[i - 1] == '1' and xx[i + 1] == '1' and (xx[i] == '0'):
		g += 1
		xx[i + 1] = '0'
print(g)


n = int(input())
a = [int(x) for x in input().split()]
w = [0] * n
for i in range(1, n - 1, 1):
	if a[i] == 0 and a[i - 1] + a[i + 1] == 2:
		w[i] = 1
ns = [0] * n
for i in range(2, n - 2, 1):
	if w[i - 1] + w[i + 1] == 2:
		ns[i] = 1
		w[i - 1] = 0
		w[i + 1] = 0
print(ns.count(1) + w.count(1))


t = int(input())
a = input()
count = 0
while '1 0 1' in a:
	a = a.replace('1 0 1', '1 0 0', 1)
	count += 1
print(count)


cases = input()
flats = [int(x) for x in input().split(' ')]
res = 0
for index in range(len(flats) - 2):
	if flats[index] == 1 and flats[index + 1] == 0 and (flats[index + 2] == 1):
		res += 1
		flats[index + 2] = 0
print(res)


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	c1 = c2 = 0
	for i in range(1, n - 1):
		if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
			c2 = c2 + 1
			a[i] = -1
			a[i - 1] = a[i + 1] = 2
	for i in range(1, n - 1):
		if a[i] == 1 and a[i - 1] == -1 and (a[i + 1] == -1):
			c1 = c1 + 1
	print(max(c2 - c1, 0))
main()


n = int(input())
x = input()
print(x.count('1 0 1'))


n = int(input())
L = list(map(int, input().split()))
c = 0
i = 0
while i < n - 2:
	if L[i] == 1:
		if L[i + 1] == 0 and L[i + 2] == 1:
			c += 1
			i += 3
			continue
	i += 1
print(c)


n = int(input())
a = list(map(int, input().split(' ')))
k = 0
count = 0
while k <= n - 3:
	if a[k] == 1 and a[k + 1] == 0 and (a[k + 2] == 1):
		count += 1
		k += 3
	else:
		k += 1
print(count)


n = int(input())
A = list(map(int, input().split()))
ans = 0
check = []
for a in A:
	check.append(a)
	if check == [1, 0, 1, 0, 1]:
		ans += 1
		check = [1]
	elif check == [1, 0, 1, 0, 0]:
		ans += 1
		check = []
	elif check == [1, 0, 1, 1]:
		ans += 1
		check = [1]
	elif check == [1, 0, 1, 0]:
		continue
	elif check == [1, 0, 1]:
		continue
	elif check == [1, 0, 0]:
		check = []
		continue
	elif check == [1, 0]:
		continue
	elif check == [1, 1]:
		check = [1]
		continue
	elif check == [1]:
		continue
	elif check == [0]:
		check = []
if check == [1, 0, 1, 0] or check == [1, 0, 1]:
	ans += 1
print(ans)


n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
d = [False] * n
if 3 < n:
	for i in range(1, n - 1):
		if a[i] == 0 and a[i - 1] == 1 and (a[i + 1] == 1):
			d[i] = True
elif a[1] == 0 and a[0] == 1 and (a[2] == 1):
	d[1] = True
ans = 0
for i in range(n):
	if d[i]:
		ans += 1
		if i + 2 <= n - 1 and d[i + 2]:
			d[i + 2] = False
print(ans)


n = int(input())
l = list(map(int, input().split()))
i = 0
count1 = 0
arr = [count1]
while i <= n - 3:
	if l[i] == 0:
		i += 1
		continue
	elif l[i] == 1 and l[i + 1] == 0 and (l[i + 2] == 1):
		count1 += 1
		l[i + 2] = 0
		i += 3
	else:
		i += 1
arr.append(count1)
while arr[-1] != arr[-2]:
	i = 0
	while i <= n - 3:
		if l[i] == 0:
			i += 1
			continue
		elif l[i] == 1 and l[i + 1] == 0 and (l[i + 2] == 1):
			count1 += 1
			l[i + 2] = 0
			i += 3
		else:
			i += 1
	arr.append(count1)
print(arr[-1])


t = int(input())
numbers = list(map(int, input().split(' ')))
rs = 0
for i in range(1, len(numbers) - 1):
	if numbers[i] == 0 and numbers[i - 1] == 1 and (numbers[i + 1] == 1):
		rs = rs + 1
		numbers[i + 1] = 0
print(rs)


n = int(input())
ara = list(map(int, input().strip().split()))
deg = [0] * len(ara)
zero = [0] * len(ara)
if ara[0] == 1:
	deg[0] += 1
if ara[len(ara) - 1] == 1:
	deg[len(ara) - 1] = 1
for i in range(1, len(ara) - 1):
	if ara[i] == 1:
		deg[i] += 1
	if ara[i] == 1 and ara[i + 1] == 0:
		deg[i] += 1
	if ara[i] == 1 and ara[i - 1] == 0:
		deg[i] += 1
	if ara[i] == 0 and ara[i - 1] == 1 and (ara[i + 1] == 1):
		zero[i] += 1
cnt = 0
for i in range(len(ara)):
	if zero[i] == 1:
		if deg[i - 1] >= deg[i + 1]:
			deg[i - 1] = 0
			deg[i + 1] = 0
			if i + 2 < len(ara):
				zero[i + 2] = 0
			if i - 2 >= 0:
				zero[i - 2] = 0
			cnt += 1
			continue
		else:
			deg[i - 1] = 0
			deg[i + 1] = 0
			zero[i + 2] = 0
			zero[i - 2] = 0
			cnt += 1
			continue
print(cnt)


n = int(input())
l = list(map(int, input().split()))
g = 0
s = []
for i in range(1, n - 1):
	if l[i] == 0 and l[i - 1] == 1 and (l[i + 1] == 1):
		g += 1
		l[i + 1] = 0
print(g)