#include using namespace std; long long MOD = 1000000007; long long p = 166666668; vector> matrix_multiplication(vector> &A, vector> &B){ int a = A.size(); int b = A[0].size(); int c = B[0].size(); vector> ans(a, vector(c, 0)); for (int i = 0; i < a; i++){ for (int j = 0; j < b; j++){ for (int k = 0; k < c; k++){ ans[i][k] = (ans[i][k] + A[i][j] * B[j][k]) % MOD; } } } return ans; } vector> matrix_exponentiation(vector> &mat, int p){ int N = mat.size(); vector> ans(6, vector(6, 0)); for (int i = 0; i < 6; i++){ ans[i][i] = 1; } while (p > 0){ if (p % 2 == 1){ ans = matrix_multiplication(ans, mat); } mat = matrix_multiplication(mat, mat); p = p / 2; } return ans; } int main(){ long long N; cin >> N; vector> mat(6, vector(6, 0)); for (int i = 0; i < 6; i++){ mat[0][i] = p; } for (int i = 1; i < 6; i++){ mat[i][i - 1] = 1; } mat = matrix_exponentiation(mat, N); cout << mat[0][0] << endl; }