#include<stdio.h>
int main(void) {
int n;
int a[10][10];
scanf("%d", &n);
int x = 0, y = 0;//坐标,爱的螺旋转圈圈
int k = 1;//循环数1~n*n
int bound0=n-1, bound1=n-1, bound2=0, bound3=1;//右下左上个方向的墙壁会向中间缩拢
int direction = 0;//0向右,1向下,2向左,3向上
while(k<=n*n){
if(direction==0){
a[x][y++] = k++;
if (y == bound0) {//向右走,遇到墙壁就向下
direction = 1;
bound0--;
}
} else if (direction == 1) {
a[x++][y] = k++;
if (x == bound1) {//向下走,遇到墙壁就向左
direction = 2;
bound1--;
}
} else if (direction == 2) {
a[x][y--] = k++;
if (y == bound2) {//向左走,遇到墙壁就向上
direction = 3;
bound2++;
}
} else if(direction == 3)
{
a[x--][y] = k++;
if (x == bound3) {//向上走,遇到墙壁就向右
direction = 0;
bound3++;
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf(" %2d",a[i][j]);
}
printf("\n");
}
}