import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))



    res = []

    remove = n

    if n % 2 != 0:

        remove -= 1



    for i in range(n):

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

            if j + 1 == remove:

                continue

            res.append([i + 1, j + 1])

        remove -= 1



    print((len(res)))

    for i in res:

        print((*i))





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))



    cnt = n

    if n % 2:

        cnt -= 1



    edge = []

    for i in range(n):

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

            if j + 1 == cnt:

                continue

            edge.append([i + 1, j + 1])

        cnt -= 1



    print((len(edge)))

    for res in edge:

        print((*res))





if __name__ == '__main__':

    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    res = []
    remove = n
    if n % 2 != 0:
        remove -= 1
    for i in range(n):
        for j in range(i + 1, n):
            if j + 1 == remove:
                continue
            res.append([i + 1, j + 1])
        remove -= 1
    print((len(res)))
    for i in res:
        print((*i))


if __name__ == "__main__":
    resolve()

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    cnt = n
    if n % 2:
        cnt -= 1
    edge = []
    for i in range(n):
        for j in range(i + 1, n):
            if j + 1 == cnt:
                continue
            edge.append([i + 1, j + 1])
        cnt -= 1
    print((len(edge)))
    for res in edge:
        print((*res))


if __name__ == "__main__":
    resolve()

+input = sys.stdin.readline -    res = [] -    remove = n -    if n % 2 != 0: -        remove -= 1 +    cnt = n +    if n % 2: +        cnt -= 1 +    edge = [] -            if j + 1 == remove: +            if j + 1 == cnt: -            res.append([i + 1, j + 1]) -        remove -= 1 -    print((len(res))) -    for i in res: -        print((*i)) +            edge.append([i + 1, j + 1]) +        cnt -= 1 +    print((len(edge))) +    for res in edge: +        print((*res))