Finding a mode is one thing versus finding all of them, e.g., {5,2} from {5,1,4,2,9,7,3,2,8,5,6}.

An endeavor to "delete" elements by writing zeroes dismisses zero as a candidate mode. We might "season" the list by adding a constant for eliminating existing noughts and later deduct as much to return each to its original number, but if the negative of the additive is present at the start, then a new nothing originates. However, supplementing the list by one higher than its largest magnitude guarantees that whatever would be last-in-line for an opportunity to end up at zero would immediately hop right over it. Less pointedly, every number would become positive.

Call this generated list "Frank" and perform a descending sort on it; with like values grouped, taking successive differences will, in addition to shortening the list by one element, intersperse zeroes between equals and nonzeroes between nonequals. Recalling that we're looking for modes, the equals are necessarily the keepers. To capture them: simultaneously convert all zeroes to ones and all nonzeroes to zeroes, prefix an additional zero to this subresult to remedy its dimension, then multiply it by our presorted Frank.

This culminates in removing one member from each cluster of matching numbers, i.e., trios get turned into duos, duos into solos, and solos into zeroes (which is not harmful to our seasoned list). Descend-sorting again would shift every "deleted" entry to the farthest right for the next pass, but let's not do that yet. Consider at this point whether all entries have now been deleted. If the largest value is indeed zero, then the iteration one prior held what survived the longest - our modes. Elsewise, take the diminished list back to the previous paragraph.

Having found only zeroes remaining, there's the reason we didn't update Frank that we may now return to it. It should contain all that we wanted (added constant notwithstanding), followed by those that didn't make it. To truncate in the former's favor, count them up, then crop. The total would be the sum of all nonzeroes identifying themselves as ones, so we'll ask them, "Are you different from zero?" Zeroes are not different from zero, so the individual answers for those are FALSE, which is zero again. Nonzeroes are comparatively not zero, so each of their answers is TRUE, which counts as one. And you sum them. And that's how many you keep.

Subtract the constant you added at the beginning of this procedure to get your modes.

:Ans→X

:1+max(abs(Ans→X

:LX+Ans

:While max(Ans

:Ans→X

:SortD(LX

:LXaugment({0},not(ΔList(LX

:End

:sum(LX xor 0→dim(LX

:LX-X