Program xuatmatranxoanoc;
uses crt;
var a:array[1..100,1..100] of Integer;
d,i,j,n:integer;
Begin
clrscr;
d:=0;
i:=0;
write('Nhap n:'); readln(n);
repeat
i:=i+1;
for j:=i to n-i do
begin
d:=d+1;
a[i,j]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[j,n+1-i]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[n+1-i,n+1-j]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[n+1-j,i]:=d;
end;
until d>=n*n-1;
if n mod 2=1 then a[(n+1) div 2,(n+1) div 2]:=n*n;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:4,' ');
writeln;
end;
readln;
End.