#include using namespace std; template vector> mat_mul(vector> a, vector> b) { vector> c(a.size(), vector(b[0].size())); for (int i = 0; i < a.size(); ++i) for (int j = 0; j < b.size(); ++j) for (int k = 0; k < b[j].size(); ++k) c[i][k] = c[i][k] + a[i][j] * b[j][k]; return c; } template vector> mat_pow(vector> a, long long p) { vector> r(a.size(), vector(a.size())); for (int i = 0; i < r.size(); ++i) r[i][i] = 1; for (; p; p >>= 1) { if (p & 1) r = mat_mul(r, a); a = mat_mul(a, a); } return r; } template struct ModInt { int val; ModInt(int v = 0) : val((v % mod + mod) % mod) {} ModInt(long long v) : val((v % mod + mod) % mod) {} ModInt &operator=(int v) { return val = (v % mod + mod) % mod, *this; } ModInt &operator=(const ModInt &oth) { return val = oth.val, *this; } ModInt operator+(const ModInt &oth) const { int u = val + oth.val; return u < 0 ? u + mod : u; } ModInt operator*(const ModInt &oth) const { return 1LL * val * oth.val % mod; } ModInt operator-() const { return val > 0 ? mod - val : 0; } }; signed main() { const int M = int(1e9 + 7); long long N; cin >> N; vector>> T = {{1, 1, 0, 0, 0}, {0, 1, 1, 2, 0}, {0, 1, 0, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 0, 1, 0}}; vector>> A1 = {{1}, {1}, {1}, {1}, {0}}; cout << mat_mul(mat_pow(T, N - 1), A1)[0][0].val << endl; return 0; }