require 'prime'
n=gets.to_i
t=n*(n+1)/2
e=t.prime_division[0][0]
g=t/e
s=g*(e-1)
q=[*1..n]
m=[]
until q.empty?
	w=0
	m<<[]
	(q.size-1).downto(0){|i|
		if w+q[i]<=g
			w+=q[i]
			m.last<<q[i]
			q.delete_at(i)
			break if w==g
		end
	}
	# assert
	raise("w != g") if w != g
end
x=0
r=""
m.size.times{|i|
	m[i].each{|k|
		(i+1...m.size).each{|j|
			m[j].each{|l|
				x+=1
				r<<"#{k} #{l}\n"
			}
		}
	}
}
puts x
puts r