permutation p order set integer p1p2pn consist n distinct positive integer do not exceed n well denote ith element permutation p pi well number n size length permutation p1p2pnwell position 1 in permutation p1p2pn good pii1 Count number permutation size n exactly k good position print answer modulo 1000000007 1097