@n = gets.chomp.to_i
@output = []

def insert_edge_odd i, n
	opposite_num = n - i
	1.upto(n) do |j|
		@output << "#{i} #{j}" if (i < j && j != opposite_num && i != n)
	end
end

def insert_edge_even i, n
	opposite_num = n + 1 - i
	1.upto(n) do |j|
		@output << "#{i} #{j}" if (i < j && j != opposite_num)
	end
end

if @n.odd?
	1.upto(@n) do |i|
		insert_edge_odd i, @n
	end
else
	1.upto(@n) do |i|
		insert_edge_even i, @n
	end
end

# ------------------------------------------------

print @output.size
print "\n"
@output.each_with_index do |x, idx|
	print x
	print "\n" unless idx == @output.size - 1 
end
