//! flag: -g3, -DWAAUTOMATON
//! link: m,stdc++
#include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef std::pair<int, int> pii;
typedef std::pair<LL, LL> pll;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;

template <typename T>
inline void chmax(T &a, T b)
{
    a = std::max(a, b);
}

template <typename T>
inline void chmin(T &a, T b)
{
    a = std::min(a, b);
}

template <typename T>
inline T sqr(const T &x)
{
    return x * x;
}

template <size_t _I_Buffer_Size = 1 << 23, size_t _O_Buffer_Size = 1 << 23>
struct IO_Tp
{
    char _I_Buffer[_I_Buffer_Size];
    char *_I_pos;
    const char *_I_end;

    char _O_Buffer[_O_Buffer_Size];
    char *_O_pos;
    const char *_O_end;

    IO_Tp()
        : _I_pos(_I_Buffer)
        , _O_pos(_O_Buffer)
        , _I_end(_I_Buffer + _I_Buffer_Size)
        , _O_end(_O_Buffer + _O_Buffer_Size)
    {
    }

    ~IO_Tp() { fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout); }

    inline char getchar()
    {
        char res = *_I_pos;
        nextchar();
        return res;
    }

    inline bool is_digit(const char ch) { return '0' <= ch && ch <= '9'; }

    inline void nextchar()
    {
        ++_I_pos;
        if (_I_pos == _I_end) {
            fread(_I_Buffer, 1, _I_Buffer_Size, stdin);
            _I_pos = _I_Buffer;
        }
    }

    template <typename Int>
    inline IO_Tp &operator>>(Int &res)
    {
        res = 0;
        int k = 1;
        while (!is_digit(*_I_pos)) {
            if (*_I_pos == '-')
                k = -1;
            nextchar();
        }
        do {
            (res *= 10) += (*_I_pos) - '0';
            nextchar();
        } while (is_digit(*_I_pos));
        res *= k;
        return *this;
    }

    inline IO_Tp &operator>>(char &res)
    {
        do {
            res = *_I_pos;
            nextchar();
        } while (res == ' ' || res == '\0' || res == '\t' || res == '\n' || res == '\r');
        return *this;
    }

    inline void putchar(char x)
    {
        if (_O_pos == _O_end) {
            fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout);
            _O_pos = _O_Buffer;
        }
        *_O_pos++ = x;
    }
    template <typename Int>
    inline IO_Tp &operator<<(Int n)
    {
        if (n < 0) {
            putchar('-');
            n = -n;
        }
        static char _buf[20];
        char *_pos(_buf);
        do
            *_pos++ = '0' + n % 10;
        while (n /= 10);
        while (_pos != _buf)
            putchar(*--_pos);
        return *this;
    }

    inline IO_Tp &operator<<(char ch)
    {
        putchar(ch);
        return *this;
    }

    inline IO_Tp &operator<<(const char *s)
    {
        while (*s != 0) {
            putchar(*s);
            ++s;
        }
        return *this;
    }
};
IO_Tp<> IO;

void solve(long long n)
{
    IO << n * (n - 1) / 2 - n / 2 << '\n';
    if (n % 2 == 0) {
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (j == n - i + 1)
                    continue;
                IO << i << " " << j << '\n';
            }
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (j == n - i)
                    continue;
                IO << i << " " << j << '\n';
            }
        }
    }
}

int main()
{
#ifdef WAAUTOMATON
    // freopen("in.txt","r",stdin);
#endif
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 2304