fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val edges = mutableListOf<Pair<Int, Int>>()

    val cntMax = if (N % 2 == 0) N else (N - 1)

    for (i in 1..cntMax) {
        for (j in i + 1..cntMax) {
            if (i + j == cntMax + 1) {
                continue
            }
            edges.add(Pair(i, j))
        }
    }
    
    if (N % 2 == 1) {
        for (i in 1 until N) {
            edges.add(Pair(i, N))
        }
    }

    println(edges.size)
    
    for ((a, b) in edges) {
        println("$a $b")
    }
}

fun readInputLine(): String {
    return readLine()!!
}
