#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; ll extgcd(ll a, ll b, ll &x, ll &y){ ll d = a; if(b!=0){ d = extgcd(b,a%b,y,x); y -= (a/b)*x; }else{ x = 1; y = 0; } return d; } ll mod_inverse(ll a, ll m){ ll x, y; extgcd(a, m, x, y); return (m+x%m)%m; } typedef vector vec; typedef vector mat; const ll MOD = 1000000007; mat mul(mat &A, mat &B){ // A*B mat C(A.size(), vec(B[0].size())); rep(i,A.size()) rep(k,B.size()){ rep(j,B[0].size()){ C[i][j] = (C[i][j]+A[i][k]*B[k][j])%MOD; } } return C; } mat pow(mat A, ll n){ // A^n mat B(A.size(), vec(A.size())); rep(i,A.size()) B[i][i] = 1; while(n>0){ if(n&1) B=mul(B,A); A=mul(A,A); n>>=1; } return B; } // 行列*ベクトル(A*v) vector mulv(mat &A, vector v){ vector ret = v; rep(i,v.size()){ ll res = 0; rep(j,v.size()){ res += A[i][j]*v[j]; res = res%MOD; } ret[i] = res%MOD; } return ret; } int main(){ ll N; cin >> N; vec a(6, 0); a[5] = 1; mat m(6, vec(6, 0)); rep(i,6){ m[i][5] = mod_inverse(6, MOD); } m[1][0] = 1; m[2][1] = 1; m[3][2] = 1; m[4][3] = 1; m[5][4] = 1; mat tmp = pow(m, N); vec ret = mulv(tmp, a); cout << ret[5] << endl; return 0; }