From: Charles Williams on
Assuming you data is sorted (or can be sorted) on column A and starts
in Row 2 then you don't need array formulas:

in column C (or somewhere suitable) add a helper column containing
and fill down
in Column D put
and fill down

If you can Sort Ascending on Column A and Descending on Column B
then you would just need this formula (filled down) in D