import kotlin.math.pow fun main() { val mod = 1_000_000_007L val n = readLine()!!.toInt() val fact = LongArray(2 * 10.0.pow(5).toInt() + 1) { 1L } for (i in 1 until fact.size) { fact[i] = fact[i - 1] * i % mod } val factInv = LongArray(fact.size) { i -> if (i == fact.lastIndex) fact.last().modPow(mod - 2, mod) else 0L } for (i in fact.lastIndex - 1 downTo 0) { factInv[i] = factInv[i + 1] * (i + 1) % mod } fun combi(a: Int, b: Int): Long { return if (0 <= b && b <= a) { fact[a] * factInv[b] % mod * factInv[a - b] % mod } else { 0L } } var ans = 0L for (i in 1..n) { ans = (ans + combi(n, i) * i.toDouble().pow((n - i).toDouble()).toLong() % mod) % mod } println(ans) } private fun Long.modPow(exponent: Long, modulus: Long): Long { var result = 1L var exp = exponent var base = this % modulus while (exp > 0) { if (exp and 1 == 1L) { result = (result * base) % modulus } base = (base * base) % modulus exp = exp shr 1 } return result }