# [J], 19 bytes (0|:0 2#:])&.(_&q:) [Try it online!](https://tio.run/##y/r/P81WT0HDoMbKQMFI2SpWU01PI16t0Erzf2pyRr5CmoK5EReUZWIAYeno6ccbmWroqKlbKag7aBirKVlp6mjoqMcZaanrmKtV62kCRfQd0jSVDGIUDLUz9QwNDP4DAA) Same as [the Jelly solution](https://codegolf.stackexchange.com/a/83815/74681). [J]: http://jsoftware.com/