#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MD=1000000007;
int p[5]= {0,1,5,11,36};
struct Matrix {
ll a[4][4];
Matrix() {
memset(a,0,sizeof(a));
}
Matrix operator*(const Matrix y) {
Matrix ans;
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
for(int k=0; k<4; k++)
ans.a[i][j]=(ans.a[i][j]+a[i][k]*y.a[k][j]+MD)%MD;
return ans;
}
void operator=(const Matrix b) {
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
a[i][j]=b.a[i][j];
}
};
ll mat_pow(ll n) {
Matrix c,res;
c.a[0][0]=c.a[0][1]=c.a[1][2]=c.a[2][3]=c.a[2][0]=1;
c.a[3][0]=-1,c.a[1][0]=5;
res.a[0][0]=36,res.a[0][1]=11,res.a[0][2]=5,res.a[0][3]=1;
while(n) {
if(n&1) res=res*c;
c=c*c;
n=n>>1;
}
//for(int i=0;i<4;i++){
// cout<<res.a[0][i]<<endl;
//}
return res.a[0][0];
}
int main() {
ll n;
while(~scanf("%lld",&n)) {
if(n<=4) {
printf("%d\n",p[n]);
} else printf("%lld\n",mat_pow(n-4));
}
return 0;
}