first, reshuffle indices so π‘Ž=1…𝑛

for each 𝑏𝑖, want to find largest subarray such that it’s some prefix of indices

for instance 𝑏=[5,1,4,2,3]

segments [1…3], [2…3], [3…3] (this is the maximum)

can be done by querying smallest empty value