program am
    implicit none
    integer::N
    integer::M
    integer,allocatable,dimension(:,:)::ANS
    integer::S

    integer::i,j
    read*,N
    allocate(ANS((N**2-N)/2,2))

    M=0
    S=N+merge(1,0,mod(N,2)==0)
    do i=1,N-1
        do j=i+1,N
            if(i+j/=S)then
                M=M+1
                ANS(M,1)=i
                ANS(M,2)=j
            endif
        end do
    end do
    print"(I0)",M
    do i=1,M
        print"(I0,A,I0)",ANS(i,1)," ",ANS(i,2)
    end do
end program am