# [Perl 6], 84 bytes

*-2 bytes thanks to Jo King*

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

    ->\n{(($!={$/=[^n];:10[map {|splice $/,$_,1},[R,] .polymod(1..n-2)]})(n+1)-$!(n))/9}

[Try it online!][TIO-jocs1jux]

[Perl 6]: https://github.com/nxadm/rakudo-pkg
[TIO-jocs1jux]: https://tio.run/##LcfdCoIwGADQV/mEERttuk/7wWI9RLdriZRC4H7Qq2E@@8ro5sAJ3Tgcko2w6UElcbm5mVKSqZkUSt@dOZ9QatsGmN9TGF6PDkjBScNx4frKDeTBD9H6J8U8d6JkZmHUbZEJklHHWFEvaWoj9JQ0DHo/QllxQKw5HFf2svq6k9UalPLHX5k@ "Perl 6 – Try It Online"

0-indexed. Doesn't enumerate all permutations. Should theoretically work for all n, but bails out for n > 65536 with "Too many arguments in flattening array".

The following **82 byte** version works for n up to 98!-2 and is a lot faster:

    {(($!={$/=[^99];:10[map {|splice $/,$_,1},[R,] .polymod(1..97)]})($_+1)-$!($_))/9}

[Try it online!][TIO-jocr9isr]

[Perl 6]: https://github.com/nxadm/rakudo-pkg
[TIO-jocr9isr]: https://tio.run/##NY3RCoIwGEZf5RdGbDV1vyt1hS/R7VgiphAoDr0S89nXFnVzzneuPtvNQ@7GFQ49VG6jlETVRtJKP5QytysKPTYWtvdih1fbAUk5qTnuXN@5gcROwzpOT4pJogpmdkZJfUIWk8gPxlK1u6VZoQ8F/TRDJjkgKg5FwEVIz7OQIWSelYU3CvHFj395U300EK5KFmfuAw "Perl 6 – Try It Online"