How to count the number of empty rows since the last entry in a column?

I’m trying to get Google Sheets to tell me how many rows it has been since the last “1” was present in column A (see example table below). How do I get Google Sheets to output column B?

An alternative way of looking at this is to count the number of zeros/blanks in between the 1’s in column A (then +1 to account for the row with the second 1) and print that number in Column B. How can I do this?

Data    # rows since last "1" 1 1       1 0 1       2 0 0 0 0 1       5 1       1 

Count max values compared with previous array

I try to count the number of values in a row that are equal are greater to MAX() value of a (part) of the column above.

For example: compared to the 3 cells above itself. In E comes the ‘count’. i marked the cells it should count with *.

enter image description here

My final array is about 200×5000… I already tried (cell E4 in example) stuff like: {=SUM(IF(A4:D4>=MAX(OFFSET(A1,ROW($ 1:$ 4)-1,0,3,1)),1,0))} {=COUNTIF(A4:D4,”>=”&MAX(OFFSET(A1,0,ROW($ 1:$ 4)-1,3,1)))}

Hoping that the ROW() & OFFSET function would split the MAX function over the columns… But none give a decent result. I can of course split the MAX() over 200 different columns on a different sheet. But I’m getting nightmare because i can’t get it done in a single array formula.