# [R], 58 bytes

<!-- language-all: lang-r -->

    b=seq(a<-scan());while(any(b-a))a=matrix(a,,2,F<-F+1)[b];F

[Try it online!][TIO-jt5okwov]

[R]: https://www.r-project.org/
[TIO-jt5okwov]: https://tio.run/##nZTBTttAFEX3/QpLbGx1Is17M2OPRViWn6i6MIiUSBBUEtRWVb89PdckILppaJZ27n13zn3jx/2qWS6a1dPmerd@2LTrrvnVbK@nzZun3bo5@3T/dDft1puvz69XD4/N7marB/uri@3Nt3ZaLvSm7brz77fru5t22vxsrxZT100X99Pucf2jnULwcLlcXH607vPVl/PL/e8Pq/a6NR6nrjtr3vuLr/KQQ3mvxVGegv/PdDvIe@YPmFQyjKEEiye52cv0gtwR9@9J4Qd5ZX5GPmJSMDtx@lE@YjBgUTCBw6nydJAXDDIWaT5Cf6o8vzn7@Hz6UE89f3khbzYDn8mrAZr4t0l/kKOzEaFVlDaQxHp5FnlmPC0JqAsLS3Y8msW/0vOSfyLDw14OM9u7jHBlxKt@OM7PePCPAXKwjymMNJkQeJlFhWqxrERDb7LEPjMxx5AwGGBAvEj9GCSFzXOQQp@a2oeBYpQr4pBxSIAi2BBDrzOxARgohac5a@HgGFSOxmIrRcRBMRIOjO7H0EeUMYwYKIX78/m5hBjUHIaCUr3goBgJB0b3NRQMRphjoBRuM6ICMgwqWwQApYg4KEbCQbWw2xiMFAUApfA4Yy8WMgaV3gGgFBEHxUg4MLpntdXKECrxlYKG1ExhaTCoFsDvSgF/VwwKmPmzBhiMVEl8paAAoWfj0dcYoO8KAX5XiiQDhHyK0I8lgN8VAv4Mhj7wbeCmcnxlgL4rRFIFCFko9CwB9F0ZwM9c4CctKFed00flx0AhoC/47ADwjR0AvisD9JkLe9AbK9Br/4iPXhmSAqDj9iBnA0DvigB77T4fEuQsAOCd/gHviuCajy4GwBv9A96VwPQBNrgn3QKGc3LaB7srgbgzlvaL7lwMVcGxMH26DeraesoHutM90F0JRB0p3Wvp6R7qPlevj74BXTtP9TB3moe5K4GgI6V5rTzNA92VAOpedBFz2f8B "R – Try It Online"

Simulates the sorting process. Input is 1-indexed, returns `FALSE` for 0.