var
a,n,q,z,l,g,ans:longint;
f,fen,h:array[-2..30004]of longint;
begin
assign(input,'diningb.in');
assign(output,'diningb.out');
reset(input);
rewrite(output);
read(n);
for n:=1 to n do
read(f[n]);
q:=1;
while f[q]=1 do inc(q);
z:=n;
while f[z]=2 do dec(z);
for a:=q to z do
if f[a]<>l then
begin
inc(g);
fen[g]:=1;
l:=f[a];
end
else inc(fen[g]);
for a:=1 to g do
if a mod 2=1 then h[a]:=h[a-2]+fen[a];
for a:=g downto 1 do
if a mod 2=0 then h[a]:=h[a+2]+fen[a];
{writeln;
for a:=1 to g do
writeln(h[a]);
writeln;}
ans:=h[1]+h[4];
for a:=1 to g do
if a mod 2=1 then
if h[a]+h[a+3]<ans then ans:=h[a]+h[a+3];
writeln(ans);
close(input);close(output);
end.