local N = io.read("n")

local edges = {}

if N % 2 == 1 then
    for i=1,N do
        for j=i+1,N do
            if j ~= N-i then
                table.insert(edges , tostring(i) .. " " .. tostring(j))
            end
        end
    end
else
    for i=1,N do
        for j=i+1,N do
            if j ~= N+1-i then
                table.insert(edges , tostring(i) .. " " .. tostring(j))
            end
        end
    end
end


print(#edges)
for _,v in pairs(edges) do
    print(v)
end

