import scala.io.StdIn
object Main extends App {
  val N = (1 to StdIn.readLine().toInt).toList
  val list = for (p <- N.permutations)
    yield p.zipWithIndex.map { case (n,i) => n % (i+1)}.sum
  println(list.max)
}
