#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
int main() {
	ifstream f1("MATRANXOAY.INP");
    ofstream f2("MATRANXOAY.OUT");
long int n,i,j;
cin>>n;
	int a[n+1][n+1];
	int d=0,gt=1,h=n-1,c=n-1;
while (d<=n/2)
{for (i=d;i<=c;i++) {a[d][i]=gt++;}
 for (i=d+1;i<=h;i++) {a[i][c]=gt++;}
  for (i=c-1;i>=d;i--){a[h][i]=gt++;}
  for (i=h-1;i>d;i--){a[i][d]=gt++;}
  d++;
  h--;
  c--;}
	for (i=0;i<n;i++)
	{for (j=0;j<n;j++)
	{cout<<a[i][j]<<setw(5);}
	 cout<<'\n';}
	return 0;
	
}
