#include using namespace std; const unsigned mod = 1000000007; class matrix { private: unsigned a, b, c, d; public: matrix() : a(0), b(0), c(0), d(0) {}; matrix(unsigned a_, unsigned b_, unsigned c_, unsigned d_) : a(a_), b(b_), c(c_), d(d_) {}; matrix& operator+=(const matrix& m) { a = (a + m.a < mod ? a + m.a : a + m.a - mod); b = (b + m.b < mod ? b + m.b : b + m.b - mod); c = (c + m.c < mod ? c + m.c : c + m.c - mod); d = (d + m.d < mod ? d + m.d : d + m.d - mod); return *this; } matrix& operator-=(const matrix& m) { a = (a < m.a ? a + mod - m.a : a - m.a); b = (b < m.b ? b + mod - m.b : b - m.b); c = (c < m.c ? c + mod - m.c : c - m.c); d = (d < m.d ? d + mod - m.d : d - m.d); return *this; } matrix& operator*=(const matrix& m) { unsigned ta = (1ULL * a * m.a + 1ULL * b * m.c) % mod; unsigned tb = (1ULL * a * m.b + 1ULL * b * m.d) % mod; unsigned tc = (1ULL * c * m.a + 1ULL * d * m.c) % mod; unsigned td = (1ULL * c * m.b + 1ULL * d * m.d) % mod; a = ta, b = tb, c = tc, d = td; return *this; } matrix operator+(const matrix& m) const { return matrix(*this) += m; } matrix operator-(const matrix& m) const { return matrix(*this) -= m; } matrix operator*(const matrix& m) const { return matrix(*this) *= m; } unsigned entry(unsigned x, unsigned y) { if (x == 0 && y == 0) return a; if (x == 0 && y == 1) return b; if (x == 1 && y == 0) return c; if (x == 1 && y == 1) return d; return -1; } }; const matrix unit(1, 0, 0, 1); matrix powersum(matrix a, long long b) { // a^0 + a^1 + a^2 + ... + a^(b-1) if (b == 1) return unit; if (b & 1) return a * powersum(a, b - 1) + unit; return (unit + a) * powersum(a * a, b >> 1); } int main() { long long n; cin >> n; matrix ret = powersum(matrix(5, 3, 3, 2), (n >> 1) + 1); int ans = (n & 1 ? ret.entry(0, 0) : ret.entry(1, 1) + mod - 1) % mod; cout << ans << '\n'; return 0; }