# CJam, distance 10

 1l~{{)_mp!}g}*

Just put `n` on STDIN. [Test it here.](http://cjam.aditsu.net/)