package no140; import java.util.Scanner; public class Main { static final long MOD = 1_000_000_007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[][] dp = new long[n+1][n+1]; long[][] c = Mod.combinationArray(n, n, MOD); dp[0][0] = 1; long ans = 0; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { dp[i][j] = (dp[i-1][j-1] + j * dp[i-1][j] % MOD) % MOD; ans = ans + c[n][i] * dp[i][j] % MOD * Mod.pow(j * (j-1) % MOD, n - i, MOD) % MOD; if (ans >= MOD) { ans -= MOD; } } } System.out.println(ans); } } class Mod { public static long[][] combinationArray(int maxN,int maxR,long mod) { long[][] c = new long[maxN+1][maxR+1]; for(int i=0;i<=maxN;i++) { c[i][0] = 1; c[i][i] = 1; } for(int i=1;i<=maxN;i++) { for(int j=1;j<=i-1;j++) { c[i][j] = c[i-1][j-1] + c[i-1][j]; if (c[i][j] >= mod) { c[i][j] -= mod; } } } return c; } public static long pow(long x,long n,long mod) { long res = 1; while(n > 0) { if ((n & 1) > 0) { res = (res * x) % mod; } x = (x * x) % mod; n/=2; } return res; } }