import math def solve(N): mod = 10**9 + 7 pat = 0 facN = math.factorial(N) for k in range(1, N+1): CNk = facN // math.factorial(k) // math.factorial(N - k) tmp = 0 for m in range(1, k+1): tmp += f(k, m) * pow(m * (m-1), N - k, mod) pat += tmp * CNk pat %= mod return pat memo = [[-1] * (555+1) for i in range(555+1)] def f(k, m): global memo if memo[k][m] >= 0: return memo[k][m] if k == m or m == 1: return 1 tmp = m * f(k-1, m) + f(k-1, m-1) memo[k][m] = tmp return tmp N = int(input()) print(solve(N))