using System; using System.Collections.Generic; using System.Linq; public class Program { static long ModFactorial(long n) { long mod = 1000000007; if (n == 0) return 1; //nがmod以上ならXは0になる if (n >= mod) return 0; long[] catche_list = { 1, 67347853, 927880474, // (1 * 10^8)! % mod 261384175, 933245637, // (2 * 10^8)! % mod 112390913, 668123525, // (3 * 10^8)! % mod 386027524, 429277690, // (4 * 10^8)! % mod 462639908, 733333339, // (5 * 10^8)! % mod 696628828, 724464507, // (6 * 10^8)! % mod 92255682, 957939114, // (7 * 10^8)! % mod 217598709, 203191898, // (8 * 10^8)! % mod 823845496, 586445753, // (9 * 10^8)! % mod 315103615, 698611116, // (10 * 10^8)! % mod }; //nを50000000で割った商がcatche_listのインデックスになり起点が求まる long start = n / 50000000; long ans = catche_list[start]; //起点から階乗の計算を始める for (long i = start * 50000000 + 1; i <= n; i++) ans = ans * i % mod; return ans; } static void func() { long mod = 1000000007; long a = 1; for (long i = 1; i < mod; i++) { a = a * i % mod; if (i % 50000000 == 0) Console.WriteLine(a); } } static void Main() { //func(); //Console.WriteLine("A"); long n; { long[] vs = Console.ReadLine().Split().Select(_ => long.Parse(_)).ToArray(); n = vs[0]; } long value = ModFactorial(n); Console.WriteLine(value); } }