using System; using System.Linq; namespace Problem1073 { class Program { static void Main(string[] args) { const long mod = 7 + (long)1e9; long N = GetLong(); var table = new long[N + 1]; for(int i = 0; i <= N; i++) { switch(i) { case 0: table[i] = 1; break; case 1: table[i] = ModInv(6, mod); break; case 2: table[i] = (table[0] + table[1]) % mod * table[1] % mod; break; case 3: table[i] = ((table[0] + table[1]) %mod + table[2]) % mod * table[1] % mod; break; case 4: table[i] = (((table[0] + table[1]) % mod + table[2]) % mod + table[3]) % mod * table[1] % mod; break; case 5: table[i] = ((((table[0] + table[1]) % mod + table[2]) % mod + table[3]) % mod + table[4]) % mod * table[1] % mod; break; case 6: table[i] = (((((table[0] + table[1]) % mod + table[2]) % mod + table[3]) % mod + table[4]) % mod + table[5]) % mod * table[1] % mod; break; default: table[i] = (((((table[i - 6] + table[i - 5]) % mod + table[i - 4]) % mod + table[i - 3]) % mod + table[i - 2]) % mod + table[i - 1]) % mod * table[1] % mod; break; } } Console.WriteLine(table[N]); } public static long ModInv(long n, long mod) { long b = mod; long u = 1; long v = 0; while (b != 0) { long t = n / b; n -= t * b; Swap(ref n, ref b); u -= t * v; Swap(ref u, ref v); } u %= mod; if(u < 0) { u += mod; } return u; } static void Swap(ref long a, ref long b) { long temp = a; a = b; b = temp; } public static int GetInt() => int.Parse(Console.ReadLine()); public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static double GetDouble() => double.Parse(Console.ReadLine()); public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray(); public static long GetLong() => long.Parse(Console.ReadLine()); public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray(); } }