local n = io.read("*n")
if(n == 3) then io.write("2\n1 3\n2 3\n")
else
  local n2 = (n % 2 == 1 and n - 1 or n)
  local lines = n2 * (n2 - 2) / 2
  local totlines = lines
  if(n % 2 == 1) then totlines = totlines + n - 1 end
  print(totlines)
  for i = 1, n2 - 1 do
    for j = i + 1, n2 do
      if(i + j ~= n2 + 1) then
        io.write(i .. " " .. j .. "\n")
      end
    end
  end
  if(n % 2 == 1) then
    for i = 1, n2 do
      io.write(i .. " " ..n .. "\n")
    end
  end
end
