#include<cstdio>
typedef long long ll;
const int N=2010,mod=1e9+7;
int n;ll f[N],g[N],C[N][N];
ll mi(ll x,ll y){
ll ans=1;
for (;y;y>>=1,x=x*x%mod)
if (y&1) ans=ans*x%mod;
return ans;
}
int main()
{
freopen("euler.in","r",stdin);
freopen("euler.out","w",stdout);
scanf("%d",&n);
for (int i=0;i<=n;i++){
C[i][0]=1;
for (int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
for (int i=1;i<=n;i++) f[i]=mi(2,(i-1)*(i-2)/2);
for (int i=1;i<=n;i++){
g[i]=f[i];
for (int j=1;j<i;j++) g[i]=(g[i]-C[i-1][j-1]*g[j]%mod*f[i-j])%mod;
if (g[i]<0) g[i]+=mod;
}
printf("%lld\n",g[n]*(n*(n-1)/2+1)%mod);
return 0;
}