const
  maxn = 1000000;
var
  h : array[1..maxn] of integer;
  n, ans, min, k, i, j, a : integer;
begin
  reset(input, 'stacks.in');
  rewrite(output, 'stacks.out');
  read(n);
  k := 0;
  for i := 1 to n do begin
    read(a);
    if (i > 1) and (a = 0) then begin
      min := 1;
      for j := 1 to k do begin
        if (h[j] < h[min]) then begin
          min := j;
        end;
      end;
      h[min] := h[min] + 1;
    end else begin
      k := k + 1;
      h[k] := 1;
    end;
  end;
  ans := 0;
  for i := 1 to k do begin
    if (h[i] > ans) then
      ans := h[i];
  end;
  writeln(ans);
end.