program F;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 n: integer;
 data: array of array of integer;
procedure LoadData;
var
 f: text;
 i: byte;
begin
 AssignFile(f,'F.in');
 Reset(f);
  Read(f,n);
  SetLength(data,n+2);
  for i:=1 to n+1 do SetLength(data[i],n+2);
 CloseFile(f);
end;

procedure Mozg;
var
 i: integer;
 step: integer;
 cx,cy: integer;
 way: (wr,wt,wl,wb);
 deaded: integer;
 twoshoot: boolean;
begin
 cx:=n div 2 + 1;
 cy:=n div 2 + 1;
 way:=wr;
 step:=1;
 deaded:=2;
 data[cx,cy]:=1;
 twoshoot:=true;

 while deaded<n*n+1 do begin

  case way of
   wr: begin
    for i:=cx+1 to cx+step do
     data[i,cy]:=deaded + i-(cx+1);
    inc(deaded,step);
    cx:=cx+step;
    way:=wt;
    twoshoot:= not twoshoot;
    if twoshoot then inc(step);
   end;

   wt: begin
    for i:=cy-1 downto cy-step do data[cx,i]:=deaded + ((cy-1)-i);
    inc(deaded,step);
    cy:=cy-step;
    way:=wl;
    twoshoot:= not twoshoot;
    if twoshoot then inc(step);
   end;

   wl: begin
    for i:=cx-1 downto cx-step do data[i,cy]:=deaded + ((cx-1)-i);
    inc(deaded,step);
    cx:=cx-step;
    way:=wb;
    twoshoot:= not twoshoot;
    if twoshoot then inc(step);
   end;

   wb: begin
    for i:=cy+1 to cy+step do data[cx,i]:=deaded + i-(cy+1);
    inc(deaded,step);
    cy:=cy+step;
    way:=wr;
    twoshoot:= not twoshoot;
    if twoshoot then inc(step);
   end;


  end;
  //inc(deaded,1);
 end;
end;

procedure WriteData;
var
 f: textfile;
 i,t: integer;
begin
 AssignFile(f,'F.out');
 ReWrite(f);
 for i:=1 to n do
 begin
  for t:=1 to n do Write(f,data[t,i],' ');
  WriteLn(f);
 end;
 CloseFile(f);
end;

begin
 LoadData;
 Mozg;
 WriteData;
end.
