Program sl;
var
i,x,n,min:longint;
s1,s2:array[0..30000]of longint;
begin
assign(input,'diningb.in');
assign(output,'diningb.out');
reset(input);
rewrite(output);
read(n);
for i:=1 to n do
begin
read(x);
s1[i]:=s1[i-1];
s2[i]:=s2[i-1];
if x=1 then inc(s1[i])
else inc(s2[i]);
end;
min:=s1[n];
if min>s2[n] then min:=s2[n];
for i:=1 to n-1 do
if (s2[i]+s1[n]-s1[i])<min then min:=(s2[i]+s1[n]-s1[i]);
writeln(min);
close(input);
close(output);
end.