import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  if (n % 2 == 0){
    println(n * (n - 2) / 2)
    for (i ← 1 to n){
      for (j ← i + 1 to n if i + j != n + 1) {
        println(s"$i $j")
      }
    }
  }else {
    println((n - 1) * (n - 1) / 2)
    for (i ← 1 to n){
      for (j ← i + 1 to n if i + j != n){
        println(s"$i $j")
      }
    }
  }
  implicit class Extension[T](val value: T) extends AnyVal {
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
    @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}