from operator import itemgetter from itertools import * from bisect import * from collections import * from heapq import * import sys sys.setrecursionlimit(10 ** 6) def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] md = 10 ** 9 + 7 n_max = 100005 fac = [1] for i in range(1, n_max + 1): fac.append(fac[-1] * i % md) ifac = [1] * (n_max + 1) ifac[n_max] = pow(fac[n_max], md - 2, md) for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1) % md def nCr(com_n, com_r): if com_n < com_r: return 0 return fac[com_n] * ifac[com_r] % md * ifac[com_n - com_r] % md def main(): n=II() ans=0 for i in range(1,n+1): cur=nCr(n,i)*pow(i,n-i,md)%md ans=(ans+cur)%md print(ans) main()