#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

ll inf = 1e9+7;

template <typename T>
T bfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    queue<T> q;
    q.emplace(source);
    vis.at(source) = true;
    while(!q.empty())
    {
        T top = q.front();
        q.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            q.emplace(tem);
            element_num++;
        }
    }
    return element_num;
}

template <typename T>
T dfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    stack<T> s;
    s.push(source);
    vis.at(source) = true;
    while(!s.empty())
    {
        T top = s.top();
        s.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            s.emplace(top);
            s.emplace(tem);
            element_num++;
            break;
        }
    }
    return element_num;
}

template <typename T>
vector<vector<T> > input_graph(T array_num, T edge_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_graph function can only be in type \"int\" or \"long long int\"!\n");
    vector<vector<T> > a(array_num, vector<T>());
    for(T i = 0; i < edge_num; i++)
    {
        T d1, d2;
        cin >> d1 >> d2;
        a.at(d1-1).emplace_back(d2-1);
        a.at(d2-1).emplace_back(d1-1);
    }

    return a;
}

template <typename T>
vector<T> input_vector(T array_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this input_vector function can only be in type \"int\" or \"long long int\"!\n");
    vector<T> a(array_num, 0);
    for(T i = 0; i < array_num; i++)
    {
        cin >> a.at(i);
    }

    return a;
}



int main() {
    int n, k, d;
    cin >> n;
    k = n*(n+1)/2;
    vector<int> a(n,0);
    vector<int> b;
    vector<int> c;
    for(int i = 0; i < n; i++)
    {
        a.at(i) = i+1;
        //cout << a.at(i) << endl;
    }
    d = k/2;
    if(k%2 == 0)
    {
        for(int i = n-1; i >= 0; i--)
        {
            //cout << d << " " << a.at(i) << endl;
            if(d >= a.at(i))
            {
                d -= a.at(i);
                b.emplace_back(a.at(i));
            }
            else
            {
                c.emplace_back(a.at(i));
            }
        }

        int bs = (int)b.size();
        int cs = (int)c.size();
        cout << (bs*cs) << endl;
        for(int i = 0; i < bs; i++)
        {
            for(int j = 0; j < cs; j++)
            {
                cout << b.at(i) << " " << c.at(j) << endl;
            }
        }
    }
    else
    {
        if(n%2 == 1)
        {
            int sum = 0;
            for(int i = 1; i <= n; i++)
            {
                for(int j = i+1; j <= n; j++)
                {
                    if(i+j == n) continue;
                    sum++;
                }
            }
            cout << sum << endl;
            for(int i = 1; i <= n; i++)
            {
                for(int j = i+1; j <= n; j++)
                {
                    if(i+j == n) continue;
                    cout << i << " " << j << endl;
                }
            }
        }
        else
        {
            int sum = 0;
            for(int i = 1; i <= n; i++)
            {
                for(int j = i+1; j <= n; j++)
                {
                    if(j == n+1-i) continue;
                    sum++;
                }
            }
            cout << sum<<endl;
            for(int i = 1; i <= n; i++)
            {
                for(int j = i+1; j <= n; j++)
                {
                    if(j == n+1-i) continue;
                    cout << i << " " << j << endl;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256