#include<stdio.h>
#define N 20
int main()
{
int c=0,i=0,j=0,out=1,n,z;
int a[N][N]={0};
scanf("%d",&n);
z=n*n;
while(out<=z)
{
i=0;
j=0;
for(i+=c,j+=c;j<n-c;j++)
{if(out>z)break;a[i][j]=out++;}
for(j--,i=i+1;i<n-c;i++)
{if(out>z)break;a[i][j]=out++;}
for(i--,j=j-1;j>=c;j--)
{if(out>z)break;a[i][j]=out++;}
for(j++,i=i-1;i>c;i--)
{if(out>z)break;a[i][j]=out++;}
c++;
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
printf("%3d ",a[i][j]);
}
for(;j<n;j++)
printf("%3d",a[i][j]);
printf("\n");
}
return 0;
}