import sys

N = int(eval(input()))



ans = []

if N % 2:

    print((N*(N-1)//2 - N//2))

    for i in range(1, N+1):

        for j in range(i+1, N+1):

            if i + j != N:

                ans.append("%d %d\n" % (i, j))

else:

    print((N*(N-1)//2 - N//2))

    for i in range(1, N+1):

        for j in range(i+1, N+1):

            if i + j != N+1:

                ans.append("%d %d\n" % (i, j))

sys.stdout.writelines(ans)
import sys

N = int(sys.stdin.readline())



ans = ["%d\n" % (N*(N-1)//2 - N//2)]

K = N+((N&1)^1)

for i in range(1, N+1):

    for j in range(i+1, N+1):

        if i + j != K:

            ans.append("%d %d\n" % (i, j))

sys.stdout.writelines(ans)
import sys

N = int(eval(input()))
ans = []
if N % 2:
    print((N * (N - 1) // 2 - N // 2))
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j != N:
                ans.append("%d %d\n" % (i, j))
else:
    print((N * (N - 1) // 2 - N // 2))
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j != N + 1:
                ans.append("%d %d\n" % (i, j))
sys.stdout.writelines(ans)

import sys

N = int(sys.stdin.readline())
ans = ["%d\n" % (N * (N - 1) // 2 - N // 2)]
K = N + ((N & 1) ^ 1)
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if i + j != K:
            ans.append("%d %d\n" % (i, j))
sys.stdout.writelines(ans)

-N = int(eval(input())) -ans = [] -if N % 2: -    print((N * (N - 1) // 2 - N // 2)) -    for i in range(1, N + 1): -        for j in range(i + 1, N + 1): -            if i + j != N: -                ans.append("%d %d\n" % (i, j)) -else: -    print((N * (N - 1) // 2 - N // 2)) -    for i in range(1, N + 1): -        for j in range(i + 1, N + 1): -            if i + j != N + 1: -                ans.append("%d %d\n" % (i, j)) +N = int(sys.stdin.readline()) +ans = ["%d\n" % (N * (N - 1) // 2 - N // 2)] +K = N + ((N & 1) ^ 1) +for i in range(1, N + 1): +    for j in range(i + 1, N + 1): +        if i + j != K: +            ans.append("%d %d\n" % (i, j))