MD Foreclosure Junior Liens

I have a question regarding forclosure sales in MD. I want to understand what happens when you buy a junion lien at foreclosure subject to other senior liens. As an example, I went to an auction where a 3rd lien foreclosed (HOA). The amount owed to the HOA was about $2000.

There was a 1st lien due for $127k and a 2nd lien due for $50k (total $177k). The winning bid for the 3rd lien was $32k subject to the 1st and 2nd liens. Does that mean the bidder needs to come up with the $32k for the 3rd lien AND an ADDITIONAL $177k for the 1st and 2nd liens (for a total of $209k)?

OR, does the excess $30k over the amount owed to the HOA get applied toward the 1st lien? In this case the bidder would need to come up with only an additional $149k, for a total owed of $179k ($127k + $50k+ $2k - $32k).

Basically, does any excess bid on junior lien get used toward paying off any senior lien?

Thanks

Paul