# [Jelly], <s>29</s> 26 bytes

    Øa;⁶,3ṗ¤
    ;L3ḍƊ¡⁶¢yZFs3¢Ṛ¤y

[Try it online!][TIO-jpjuuooe]

[Jelly]: https://github.com/DennisMitchell/jelly
[TIO-jpjuuooe]: https://tio.run/##y0rNyan8///wjETrR43bdIwf7px@aAmXtY/xwx29x7oOLQQKHlpUGeVWbHxo0cOdsw4tqfx/uP1R0xqFyP//lUoyMosVgChRoaQoMy0zRSE5syAjtUhJR0GpJLW4BETnl5YUlIJZECVQFQA "Jelly – Try It Online"