program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,s

    read*, n
    s = sum([(i, i=1,n)])
    print'(i0)', (n*(n-1))/2 - n/2
    do i=1,n
        do j=i+1,n
            if (j == n-i) cycle
            print'(*(i0,1x))', i,j
        end do
    end do
end program main