# [J], 13 bytes

    [{.[:,1++/&i.

[Try it online!][TIO-jwb0pkgm]

[J]: http://jsoftware.com/
[TIO-jwb0pkgm]: https://tio.run/##PZE7TgNBEAVzn6JEgLFsL9Of/UpESEREpA4RliHhABx@2dm3IPWEM1NV/TXfNfsrTxN7ThSm5Zwbnt9eX@bLT3OZTnY8Pt5/NvNh9/F@@@YhR67YgfOE4QRJS0fPwIgVzDDHAkusxTqsxwZsxAu@3HE88MRbvMN7fMBHohBGLE8GkURLdERPDMRIFtJIJ5cfk2zJjuzJgRw3NCtlYfN/tkpX@SphZayUlbOSilW4Iha0uIUuegnIYdXYTCQjHynJSmJyk54MV8nNU6qylbCcpS1zyct/TbBVUAi1UA4VURR1URrVqYHqtGUd@4sVS6tYW22L1DK1UC213c2/ "J – Try It Online"