=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
{QUERY(QUERY(TRANSPOSE(QUERY(TRANSPOSE({
QUERY( Q2:Q, "limit "&COUNTA(Q2:Q)),
QUERY(OFFSET(Q2:Q, -1, 0), "limit "&COUNTA(Q2:Q)-1)}),
"select "®EXREPLACE(JOIN(, IF(LEN(Q2:Q),
"max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
"select Col2"),
"limit "&COUNTA(Q2:Q)),
{""; QUERY(TRANSPOSE(QUERY(TRANSPOSE({
QUERY( Q2:Q, "limit "&COUNTA(Q2:Q)),
QUERY(OFFSET(Q2:Q, -1, 0), "limit "&COUNTA(Q2:Q)-1)}),
"select "®EXREPLACE(JOIN(, IF(LEN(Q2:Q),
"max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
"select Col2
limit "&COUNTA(Q2:Q)-1)}}),
"select "®EXREPLACE(JOIN(, IF(LEN(Q2:Q),
"max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
"select Col2"))