require 'set'

N = gets.chomp.to_i

S = Set.new
def add(a, b)
  if (a > b)
    S << [b, a]
  else
    S << [a, b]
  end
end

if N % 2 == 0
  # Now, we make N/2 pairs.
  1.upto(N/2).each do |i|
    p = N+1-i
    # i is the pair of (N+1-i).
    # We make pair with all others.
    1.upto(N).each do |j|
      if (j != i) && (j != p)
        add(i, j)
        add(p, j)
      end
    end
  end
else # odd
  # Now, we make N/2 + 1 pairs
  # [1,N-1],[2,N-2],..[(N-1)/2,(N-1)/2+1], N
  1.upto(N/2).each do |i|
    # i is the pair of N-i.
    p = N-i
    1.upto(N-1).each do |j|
      if (i != j) && (p != j)
        add(i, j)
        add(p, j)
      end
    end
    add(i, N)
    add(p, N)
  end
end
  
p S.size
S.each do |(i, j)|
  print "#{i} #{j}\n"
end