Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N = NextInt()
        Dim M = Pow(10, 9) + 7

        Dim ans = 1L

        For i As Integer = 1 To N
            Dim j = i Mod M
            ans = (ans * j) Mod M
        Next

        WriteLine(ans)
    End Sub

    Function Pow(a As Long, b As Integer) As Long
        Dim result = 1L
        For i = 1 To b
            result *= a
        Next
        Return result
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
