include

include

using namespace std;
int mm = 1e9 + 7;

vector<vector<long long="">> matriMulti(vector<vector<long long="">> &m1,vector<vector<long long="">> &m2)
{</long></long></long>

int r=m1.size();
int c=m1[0].size();
vector<vector<long long>> res(r,vector<long long>(c,0));
for(int i=0;i<r;i++)
    for(int j=0;j<c;j++)
        for(int k=0;k<c;k++)
        {
             res[i][j]=(res[i][j]+(m1[i][k]*m2[k][j])%mm)%mm;
        }
return res;

}
void multi(vector<vector<long long="">> &res,vector<vector<long long="">> &m,long long n)
{</long></long>

res[0][0]=1;
res[0][1]=0;
res[0][2]=0;
res[1][0]=0;
res[1][1]=1;
res[1][2]=0;
res[2][0]=0;
res[2][1]=0;
res[2][2]=1;
vector<vector<long long>> mtemp=m;
while(n!=0)
{
    if(n&1==1)
        res=matriMulti(res,mtemp);
   mtemp=matriMulti(mtemp,mtemp);
    n=n>>1;
}

}

long long f3(long long n)
{
if(n<1)
return 0;
if(n==1)
return 1;
if(n==2)
return 2;
if(n==3)
return 3;

vector<vector<long long>> m(3,vector<long long>(3,0));
vector<vector<long long>> res(3,vector<long long>(3,0));
m[0][0]=1;
m[0][1]=1;
m[0][2]=0;
m[1][0]=0;
m[1][1]=0;
m[1][2]=1;
m[2][0]=1;
m[2][1]=0;
m[2][2]=0;
multi(res,m,n-3);
return (3*res[0][0]+2*res[1][0]+res[2][0])%mm;

}
int main()
{

long long n;
cin >> n;

int result = f3(n);

cout << result;

return 0;

}