#include <iostream>
#include <math.h> //log10(), floor()

int main()
{
    int num, holder;
    int count = 1;

    std::cin >> num;
    const int n = num > 0 ? num : -num;
    int spiral[n][n];
    int spaces = log10(n*n)+2; //stolen from /u/J354

    for (int d = 0; d < n/2 + n%2; d++)
    { //Constructs the spiral one layer at a time
        for (int c = d; c < n-d-1; c++)
        { //Constructs the four sides of the layer
            spiral[d][c] = count;
            spiral[c][n-1-d] = (n-1-2*d) + count;
            spiral[n-1-d][n-1-c] = 2*(n-1-2*d) + count;
            spiral[n-1-c][d] = 3*(n-1-2*d) + count;
            count++;
        }
        count += 3*(n-1-2*d);
    }
    //Dirty fix for odd n
    if (n%2) {spiral[n/2][n/2] = n*n;}

    if (num < 0)
    { //Flip if negative input
        for (int i = 0; i < n; i++)
        {
            for (int j = i; j < n; j++)
            {
                holder = spiral[i][j];
                spiral[i][j] = spiral[j][i];
                spiral[j][i] = holder;
            }
        }
    }

    for (int i = 0; i < n; i++)
    { //Print output
        for (int j = 0; j < n; j++)
        {
            for (int s = spaces-floor(log10(spiral[i][j]))-1; s > 0; s--) {std::cout << " ";}
            std::cout << spiral[i][j];            
            if (j == n-1) {std::cout << "\n";}
        }
    }

    return 0;
}