#include #include using namespace std; using namespace atcoder; using mint = modint1000000007; const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } vector> mul(vector>&A, vector>&B) { vector> C(A.size(), vector(B[0].size())); rep(i, A.size()) rep(j, B[0].size()) rep(k, A[0].size()) C[i][j] += A[i][k] * B[k][j]; return C; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long n; cin >> n; vector> mans(8, vector(8)); vector> mpow(8, vector(8)); rep(i, 8)mans[i][i] = 1; mpow[0] = { 1,2,1,1,0,0,0,0 }; mpow[1] = { 0,1,0,1,0,0,0,0 }; mpow[2] = { 1,0,0,0,0,0,0,0 }; mpow[3] = { 0,1,0,0,0,0,0,0 }; mpow[4] = { 0,0,1,0,0,0,0,0 }; mpow[5] = { 0,0,0,1,0,0,0,0 }; mpow[6] = { 0,0,0,0,1,0,0,0 }; mpow[7] = { 0,0,0,0,0,1,0,0 }; vectorv = { 1,1,1,3,2,7,3,15 }; if (n < 8) { cout << v[n].val() << endl; return 0; } long long copyn = n; if (0 == copyn % 2)copyn++; copyn = (copyn - 7) / 2; while (copyn > 0) { if (1 == copyn % 2) mans = mul(mpow, mans); copyn /= 2; mpow = mul(mpow, mpow); } mint ans = 0; if (1 == n % 2) { rep(i, 8)ans += mans[0][i] * v[7 - i]; } else { rep(i, 8)ans += mans[1][i] * v[7 - i]; } cout << ans.val() << endl; return 0; }