N = gets.to_i

edges = Array.new(N + 1) { Array.new(N + 1, true) }

if N.even?
  1.upto(N) do |i|
    edges[i][N - i + 1] = false
    edges[N - i + 1][i] = false
  end
else
  1.upto(N - 1) do |i|
    edges[i][N - i] = false
    edges[N - i][i] = false
  end
end

ans = []

1.upto(N) do |a|
  1.upto(N) do |b|
    next if a == b
    next if !edges[a][b]

    ans << [a, b]
    edges[b][a] = false
  end
end

puts ans.size
puts ans.map { |a, b| [a, b].join(' ') }
