#include <iostream>
using namespace std;
const int M=1000000007;
typedef long long ll;
int main()
{
int i,n;
cin>>n;
ll a[1010],b[1010];
b[1]=1;
for(i=2;i<=n;i++)
b[i]=b[i-1]*2%M;
a[1]=1;
a[2]=6;
for(i=3;i<=n;i++)
a[i]=(a[i-1]*2+a[i-2]*4+b[i])%M;
ll re;
re=a[n]*4%M;
for(i=2;i<n;i++)
{
ll l,r;
l=b[i-1]*a[n-i]*2*2%M;
r=b[n-i]*a[i-1]*2*2%M;
re=(re+(l+r)*2%M)%M;
}
cout<<re<<endl;
return 0;
}