program main
  implicit none
  integer :: N
  integer :: i,j
  integer :: iskip
  read(*,*) N

  if (mod(N,2)==0) then ! even
     write(*,'(i0)' ) N*(N-1)/2 - N/2
     iskip = N
     do i = 1,N-1
        do j = i+1,N
           if (j==iskip) then
              iskip = iskip-1
              cycle
           end if
           write(*,'(i0,x,i0)') i,j
        end do
     end do
  else  ! odd
     write(*,'(i0)' ) N*(N-1)/2 - (N-1)/2
     iskip = N-1
     do i = 1,N-1
        do j = i+1,N
           if (j==iskip) then
              iskip = iskip-1
              cycle
           end if
           write(*,'(i0,x,i0)') i,j
        end do
     end do
  end if
  stop
end program main
