#include<iostream>
#include<cstring>
#define N 105
using namespace std;
int Mat[N][N];
void Output(int n);
int main()
{
int n;
cin>>n;
Output(n);
return 0;
}
void Output(int n)
{
int i,j,cnt=1;
memset(Mat,0,sizeof(Mat));
i = 1; j = n; //初始位置是第一行最后一列
while(cnt<=n*n)//方阵里面共有n*n个数
{
while(j > 0 && i <=n && !Mat[i][j])Mat[i++][j] = cnt++;
i--;j--; //向下时由上面超出了,故要回退,并且这时列也要移到下个开始点,下同
while(j > 0 && !Mat[i][j]) Mat[i][j--] = cnt++;
j++;i--;
while(i > 0 && !Mat[i][j]) Mat[i--][j] = cnt++;
i++;j++;
while(j <=n && !Mat[i][j]) Mat[i][j++] = cnt++;
j--;i++;
}
for (i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if (j!=1) //不是第一个则输出空格
cout<<' '<<Mat[i][j];
else
cout<<Mat[i][j];
}
cout<<endl;
}
}