n = int(input()) c = [0]*(n+1) cnt = n*(n-1)//2 cur = n res = [] s = set() while cnt > 0: tmp = cur-1-c[cur] for i in range(tmp): res.append((cur, cur-1-i)) c[cur] += 1 c[cur-1-i] += 1 cnt -= 1 for i in range(n, 0, -1): s.add(c[i]) if len(s) == n-1: break cur -= 1 # print(c) print(len(res)) for i in range(len(res)): a, b = res[i] print(n+1-a, n+1-b)