1stly, if I'm not wrong, the qsn needs slight modification..
The last term is not na1, but n2a1.
If u need the function it is 2.n!-n-1.
Do not ask me to derive it. I saw the soln in a book by Andreescu, Feng & Lee, where they used induction to prove that an is the number of derangements of the set of the 1st n naturals.....
I can however copy-paste it if anyone desires to have a look.......