const fi='';
      fo='';
var   f:text;
      n,i,dem,min:longint;
      A,B:array[-69..10000000] of longint;
(*===============================*)
BEGIN
assign(f,fi);
reset(f);
readln(f,n);
close(f);
(*===============================*)
assign(f,fo);
rewrite(f);
for i:=1 to n do
 if n mod i=0 then
  begin
   inc(dem);
   A[dem]:=i;
  end;
for i:=1 to dem do B[i]:=A[i]-(n div A[i]);
min:=maxlongint;
for i:=1 to dem do if (B[i]>=0) and (B[i]<min) then min:=B[i];
for i:=1 to dem do if B[i]= min then begin writeln(f,n div A[i],' ',A[i]); break; end;
close(f);
END.

var
  n,i:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
  if n mod i=0 then begin writeln(i,' ',n div i);exit;end;
end.

{CF747A}
var
n,i:longint;
begin
read(n);
for i:=trunc(sqrt(n)) downto 1 do
 if n mod i=0 then
 begin
 writeln(i,' ',n div i);
 halt;
 end;
end.

var i,e,n:longint;
 begin
  readln(n);
  e:=(n div 2)+1;
  for i:=round(sqrt(n)) downto 1 do
   if n mod i=0 then begin
                      if (n div i)<i then
                                      writeln(n div i,' ',i)
                                       else
                                        writeln(i,' ',n div i);
                                         exit;
                                         end;
 end.

var n,i,j,x:longint;
        min:longint;
begin

        readln(n);
               min:=n*2;
        for i:=1 to n do
                if n mod i=0 then
                begin
                        //write(i,' ',abs (i - (n div i)));
                        if abs (i - (n div i)) < min then
                        begin
                                min:= abs (i - (n div i));
                                x:=i;
                        end;
                end;
        write(x,' ',n div x);
end.

var i,j,res,ires,jres,n:longint;
begin
    readln(n);
    res:=round(1e9);
    for i:=1 to 1000000 do
        if n mod i=0 then
            begin
                j:=n div i;
                if (i<=j) and (abs(i-j) <res) then
                    begin
                        res:=abs(i-j);
                        ires:=i;
                        jres:=j;
                    end;
            end;
        writeln(ires,' ',jres);
end.

var n,i:longint;
  begin
    readln(n);
      for i:=round(sqrt(n)) downto 1 do
        if n mod i =0 then begin writeln(i,' ',n div i); break; end;
     end.

Var n,max,c1max,c2max,i,c1,c2:longint;
Begin
     readln(n);
     max:=n-1;
     c1max:=1;
     c2max:=n;
     For i:=1 to n div 2 do
     begin
     c1:=i;
     c2:=n div c1;
     if c1*c2=n then if abs(c1-c2)<max then begin
                                            c1max:=c1;
                                            c2max:=c2;
                                            max:=abs(c1-c2);
                                            end;
    end;
    writeln(c1max,' ',c2max);
End.

var
n,a1,i,b1,b,a,min:longint;
begin
min:=1000000;
readln(n);
for i:=1 to trunc(sqrt(n)) do begin
if n mod i = 0 then begin
a1:=i;
b1:=n div i;
if b1-a1 <min then begin
min:=b1-a1;
a:=a1;
b:=b1;
end;
end;
end;
writeln(a,' ',b);
end.

var
n,i,ind,min:longint;
begin
readln(N);
min:=1000000000;
for i:=1 to n do begin
    if n mod i = 0 then begin
        if n div i >=i then begin
            if (n div i - i )<=min then begin
                min:=n div i - i;
                ind:=i;
            end;
        end;
    end;
end;
writeln(ind,' ',n div ind);
end.

var n,i,j:longint;
begin
readln(n);
i:=trunc(sqrt(n));
while (i>0) do
begin
if n mod i=0 then begin writeln(i,' ',n div i);break end;
i:=i-1;
end;
end.

var n,a:longint;
begin
readln(n);
a:=trunc(sqrt(n));
while n mod a<>0 do
        a:=a-1;
write(a,' ',n div a);
readln
end.

var t,z,i,n,k: longint;
    a: array [1..1000] of longint;
    b: array [1..300] of longint;
begin
z:=0;
readln (k);
if k=2 then writeln ('1 2') else
if k=1 then writeln ('1 1') else
begin
while z*z<k do
      begin
      z:=z+1;
      end;
t:=1;
for i:=1 to z do
    if (k mod i)=0 then
       begin
       a[t]:=i;
       b[t]:=k div i;
       t:=t+1;
       end;
t:=t-1;
if a[t]<b[t] then writeln (a[t],' ', b[t])
else writeln (b[t], ' ', a[t]);
end;
end.

var
        n,a,b:longint;

procedure mo;
begin
        assign(input,'387A.inp');reset(input);
        assign(output,'387A.out');rewrite(output);
end;

procedure xuli;
var i:longint;
begin
        for i:=1 to trunc(sqrt(n)) do
                if n mod i=0 then
                        begin
                        a:=i;
                        b:=n div i;
                        end;
end;

begin
        readln(n);
        xuli;
        writeln(a,' ',b);
end.

var d : real;
n, i : longint;

begin
readln(n);
d:=n;
i:=0;
repeat
if n mod (round(sqrt(d))-i)=0 then
begin
  writeln(round(sqrt(d))-i, ' ', n div (round(sqrt(d))-i));
  break;
end;
Inc(i);
until false;

end.

var
        n,max,a,b:int64;
        i:longint;
begin
readln(n);
max:=maxlongint;
for i:=1 to n do
        if n mod i=0 then
                begin
                if i<=n div i then
                        begin
                        if n div i-i<max then
                                begin
                                max:=n div i-i;
                                a:=i;
                                b:=n div i;
                                end;
                        end
                else
                        break;
                end;
writeln(a,' ',b);
end.

uses math;
var
 n,i,a,b,minn: longint;
begin
 readln(n);
 if n = 1 then begin writeln(1,' ',1); halt; end;

 minn:=maxlongint;
 for i:=2 to n do
 if n mod i = 0 then
  if abs(i-n div i) < minn then
  begin
   minn:=abs(i-n div i);
   a:=min(i,n div i);
   b:=max(i,n div i);
  end;

 writeln(a,' ',b);
end.

var
  n, a, b, i : longint ;

begin
  read(n);
  for i := trunc(sqrt(n)) downto 1 do
    if n mod i = 0  then
      begin
        a := i ; b:= n div i ;
        break ;
      end;
  write(a,' ', b) ;
end .

var
   i,n,hieu,a,b,x:longint;
procedure nhap;
   begin
     readln(n);
   end;
BEGIN
  nhap;
  hieu:=n;
  for i:=1 to trunc(sqrt(n)) do
      begin
        x:=n div i;
        if i*x=n then
           begin
             if hieu>x-i then
                begin
                  a:=i;
                  b:=x;
                end;
           end;
      end;
  writeln(a,' ',b);
END.

var
n,min,a,i,otv,otv1:longint;
begin
readln(n);
min:=1000000;
a:=n;
for i:=1 to n do begin
if n mod i = 0 then begin
a:=n div i;
if (i<=a) and ((a-i)<min)then begin
min:=a-i;
otv:=a;
otv1:=i;
end;
end;
end;
writeln(otv1,' ',otv);
end.

var n,i,j,a,b:longint;
begin
  readln(n);
  for i:=1 to trunc(sqrt(n)) do
    if (n mod i = 0) then begin a:=i; b:=n div i; end;
  writeln(a,' ',b);
end.

var a,b,x,i,n,a1,b1:longint;
begin
readln(n);
x:=244678946;
for i:=1 to n do
 if n mod i = 0
  then
   begin
   if n div i < i then a1:= n div i else a1:=i;
   b1:=n div a1;
   if x > b1 - a1 then
          begin
          x:=b1 - a1;
          a:=a1;
          b:=b1;
          end;
   end;
  write(a,' ',b);
end.

Var
                N,i,a,b         :Longint;
BEGIN
                Readln(N);
                For i := Trunc(Sqrt(N)) downto 1 do
                If N mod i=0 then
                        Begin
                                a := i; b := n div i; break;
                        End;
                Writeln(a,' ',b);
END.

var
  n,i:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do if n mod i=0 then begin writeln(i,' ',n div i);exit;end;
end.

{$MODE OBJFPC}
var
     n : integer;
     min,vt,i : integer;
BEGIN
     readln(n);
     min:= trunc(1e6);
     for i:=1 to trunc(sqrt(n)) do
          if (n mod i = 0) then
          begin
               if abs((n div i) - i) < min then
                    begin
                         min:= abs((n div i) - i);
                         vt:= i;
                    end;
          end;
     write(vt,' ',n div vt);
END.

Program abc;
var a,i,b,c,min1,min2,otv: integer;
begin
read(a);
otv:=a;
for i:=1 to a do
begin
if a mod i=0 then
begin
if abs((a div i)-i)<=otv then
begin
otv:=abs((a div i)-i);
min1:=a div i;
min2:=i;
end;
end;
end;
if min1>min2 then writeln(min2,' ',min1);
if min2>min1 then writeln(min1,' ',min2);
if min2=min1 then writeln(min1,' ',min2);

end.

Var n,i,pr:int64;
Begin
  readln(n);
  i:=1;
  while i*i<n do begin
                 if n mod i=0 then pr:=i;
                 i:=i+1;
                 end;
  if i*i=n then pr:=i;
  writeln(pr,' ',n div pr);
End.

const
     fin='';fon='';
var
     n:longint;
procedure nhap;
     begin
          assign(input,fin);reset(input);
          assign(output,fon);rewrite(output);
          readln(n);
     end;
procedure solve;
     var
          i:longint;
     begin
          i:=trunc(sqrt(n));
          while n mod i<>0 do
               dec(i);
          write(i,' ',n div i);
     close(input); close(output);
     end;
begin
     nhap;
     solve;
end.

program mon; //http://codeforces.com/problemset/problem/747/A

function check(const pixels, wid, heg: longint): boolean;
begin
	check:= ((pixels div wid) = heg) and (wid >= heg) and ((pixels mod wid) = 0);
end;

var i, heg, wid, mid, pixels: longint;
begin
	readln(pixels);
	wid:= pixels;
	heg:= pixels div wid;
	for i:= 1 to pixels do begin
		if check(pixels, pixels div i, i) then begin
			wid:= i;
			heg:= pixels div i;
		end;
	end;
	writeln(wid, ' ', heg);
	readln();
end.

var n,i,u,v:longint;
begin
 readln(n);
 for i:=1 to trunc(sqrt(n)) do
  if n mod i = 0 then
   begin
    u:=i;
    v:=n div i;
   end;
 write(u,' ',v);
end.

var i,n,a,b,res,x,y:longint;
begin
//assign(input,'a.inp');reset(input);
//assign(output,'a.out');rewrite(output);
readln(n);
res:=maxlongint;
for i:=1 to 100000 do
    if n mod i=0 then
        begin
            a:=i;
            b:=n div i;
            if a<=b then
            if b-a<res then
                begin
                    res:=b-a;
                    x:=a;
                    y:=b;
                end;
        end;
writeln(x,' ',y);
end.

var n, a, b, aa, bb, f: longint;
    i: integer;
begin
readln(n);
f:=n;
for i:=1 to round(sqrt(n)) do
  begin
  if n mod i=0 then
    begin
    a:=(i+n div i-abs(i-n div i)) div 2;
    b:=i+n div i-a;
    if a-b<f then
      begin
      aa:=a;
      bb:=b;
      f:=a-b;
      end;
    end;
  end;
  writeln(a, ' ', b);
end.

const    fi = '747a.inp';
         fo = '747a.out';
         maxn = 100005;
var
   n:longint;

procedure enter;
var   i:longint;
begin
   readln(n);
end;

procedure solve;
var   i:longint;
begin
   for i:=trunc(sqrt(n)) downto 1 do
   if n mod i=0 then
   begin
      writeln(i,' ',n div i);
      break;
   end;
end;

BEGIN
  ////// assign(input,fi); reset(input);
  // assign(output,fo); rewrite(output);
   enter;
   solve;
   close(input); close(output);
END.

const
   fi='747a.inp';
   fo='747a.out';
var
   f:text;
   n:longint;
   a,b,a1:longint;
procedure doc;
begin
   //assign(f,fi);reset(f);
   read(n);
   //close(F);
end;

procedure xuli;
begin
   for a:=1 to trunc(sqrt(n)) do
      begin
         if n mod a=0 then
            begin
               a1:=a;
               b:=n div a;
            end;
      end;
end;

procedure ghi;
begin
   write(a1,' ',b);
end;

begin
   doc;
   xuli;
   ghi;
end.

  var n : LongInt;
      a , b , a1 , b1 : LongInt;
begin

  readLn ( N ) ;

  for a := 1 to N do
  begin

    if ( N mod A = 0 ) and ( a <= N div A ) then
    begin
      a1 := a;
      b1 := N div A;
    end;

  end;

  writeLn ( a1 , ' ' , b1 ) ;

end.

const
        fi='';
        fo='';
var     f:text;
        n:longint;
        a,b:longint;
{}
procedure docf;
var     i:longint;
begin
        assign(f,fi); reset(f);
        readln(f,n);
        close(f);
end;
{}
procedure lam;
var     i:longint;
begin
        a:=1; b:=n;
        for i:=2 to trunc(sqrt(n))+1 do
        if n mod i =0 then
        if (i <= n div i) then
        begin
                a:=i;
                b:=n div i;
        end;
end;
{}
procedure xuat;
begin
        assign(f,fo); rewrite(f);
        writeln(f,a,' ',b);
        close(f);
end;
{}
begin
        docf;
        lam;
        xuat;
end.

var n, a, b: LongInt;
    i, st, rb: LongInt;

begin

  readln (n);
  st := n;

  for i := 1 to n do
  begin
    a := i;
	b := n div a;
    if (n mod a = 0) and (abs (a - b) < st) then
	begin
	  rb := n div a;
	  st := abs (a-b);
	end;
  end;

  a := n div rb;
  writeln (a,' ',rb);

end.

var
        n,kq,i,j,x,y:longint;
begin
        readln(n);
        kq:=high(longint);
        for i:=1 to 1000 do
        begin
                j:=n div i;
                if i>j then break;
                if (j-i<kq) and (i*j=n) then
                begin
                        kq:=j-i;
                        x:=i;
                        y:=j;
                end;
        end;
        write(x,' ',y);
end.

var n,i: longint;
begin
        reset(input);
        readln(n);
        for i:=trunc(sqrt(n)) downto 1 do
        begin
                if n mod i=0 then
                begin
                        writeln(i,' ',n div i);
                        break;
                end;
        end;
end.

var n,i,m,a,b,x,y:longint;

begin
readln(n);
m:=maxlongint;
for i:=1to trunc(sqrt(n)) do
    if n mod i=0 then
      begin
      a:=i;b:=n div i;
      if b-a<m then
        begin
        x:=a;y:=B;M:=B-A;
        END;
      end;
writeln(x,' ',y);
end.

var
  a:array[0..1000]of longint;
  s,s1:ansistring;
  i,j,m,n,max,maxx:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
    if n mod i=0 then break;
  writeln(i,' ',n div i);
end.

var
 i,n:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
    if n mod i=0 then
      begin
        writeln(i,' ',n div i);
        exit;
      end;
end.

var a, d, e, i, b, f, c: longint;
begin
read(a);
c:=a;
for i:=1 to a do
begin
if a mod i=0 then
begin
b:=a div i;
if ((i-b<c) or (i-b=c)) and ((i-b>0) or (i-b=0)) then
begin
c:=i-b;
e:=i;
f:=b;
end;
end;
end;
writeln(f,' ',e);
end.

var n,a:integer;
begin
read(n);
for a:=round(sqrt(n)) downto 1 do
  if n mod a=0 then begin
    write(a,' ',n div a);
    break;
  end;
end.

var
    n, i, min, am, bm, a, b : longint;
begin
    readln(n);
    min := 1000000;
    for i := 1 to trunc(sqrt(n)) do begin
        if (i * trunc(n div i) = n) and (i <= trunc(n div i)) then begin
            //write(i, ' ', trunc(n div i));
            a := i;
            b := trunc(n div i);
            //writeln(abs(a- b));
            if (abs(a - b) < min) then begin
                min := abs(a-b);
                am := a;
                bm := b;
            end;
        end;
    end;
    write(am, ' ', bm);
end.

var n,i,r,x,y:longint;
begin
readln(n);
r:=n;
for i:=1 to n do
if (n mod i=0)and(abs(i- n div i)<r) then begin
                                           x:=i;
                                           y:=n div i;
                                           r:=abs(x-y)
                                           end;
     if x>y then writeln(y,' ',x)
     else writeln(x,' ',y)
     end.

var
i:integer;
n, maxdel: longint;
begin
	readln(n);
	i:=1; maxdel:=0;
	while (i*i<=n) Do begin
	if (n mod i = 0) then
		maxdel:=i;
		i:=i+1;
		end;
	write(maxdel, ' ', n div maxdel);
	writeln;
end.

var
  ans,a,b,i,n,k,j:longint;
  x,y:array[1..111111]of longint;
begin
  read(n);
  i:=2;
  j:=0;
  for i:=1 to n do
  if (n mod i=0) then begin j:=j+1;x[j]:=n div i;y[j]:=i;end;

  ans:=1000000000;
  for i:=1 to j do
  if abs(x[i]-y[i])<ans then begin ans:=abs(x[i]-y[i]);k:=i;end;
  if x[k]>=y[k] then writeln(y[k],' ',x[k]) else writeln(x[k],' ',y[k]);
end.

var
  a, b, c, d, i, min, min_i: int64;

begin
  readln(a);
  i := 1;
  min := a;
  while i <= a do begin
    if (a mod i = 0) and (i - a div i < min) and (i >= a div i)  then begin
      min := i - a div i;
      min_i := i;
    end;
    inc(i);
  end;
  writeln(a div min_i, ' ', min_i);
end.

var n,i:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
    if n mod i=0 then
    begin
      writeln(i,' ',n div i);
      halt;
    end;
end.

var
    n,i:longint;
begin
    readln(n);
    for i:=trunc(sqrt(n)) downto 1 do
        if n mod i=0 then
        begin
            writeln(i,' ',n div i);
            exit;
        end;
end.

Var i , n , tmp , Ans : Longint;

Begin
    tmp := High(Longint);
    Readln(n);
    For i := 1 to Trunc(Sqrt(n)) do
        If (n mod i = 0) then
            If (n div i) - i < tmp then
                Begin Ans := i; tmp := (n div i) - i; End;

    Write(Ans , ' ' , n div Ans);
End.

var n,k:longint;
begin
readln(n);
k:=trunc(sqrt(n));
while n mod k>0 do dec(k);
write(k,' ',n div k);
readln;
end.

var a,b: longint;
    i,n: longint;
begin
 readln(n);
 b:=1000000;
 a:=0;
 for i:=1 to n do
  if (n mod i=0) and (abs(i-n div i)<abs(b-a)) then
   if (i>=n div i) then begin
    a:=n div i;
    b:=i;
   end
   else begin
    a:=i;
    b:=n div i;
   end;
  write(a,' ',b);
end.

{$Q-}{$R-}

USES    math;

CONST   signature='D_H_T_A_V';
        fip='1.inp';
        fop='1.out';

VAR     n,i:longint;

 PRocedure nhap;
 begin
        read(n) ;
 end;

 PRocedure xuly;
 begin
        for i := trunc(sqrt(n)) downto 1 do
        begin
                if n mod  i = 0 then
                begin
                        write(i,' ', n div i) ;
                        exit;
                end;
        end;
 end;

 Procedure endpro;
 begin
        close(input) ; close(output);
 end;

BEGIN
      //  Assign(input,fip); reset(input);
     //   ASsign(output,fop); rewrite(output);
        nhap;
        xuly;
     //   endpro;
END.

var n,max,i,r:integer;
begin
readln(n);
max:=1000001;
For i:=1 to n do
 If n mod i = 0 then
                 If abs(i-(n div i))<max
                  then begin
                        max:=abs(i-(n div i));
                        r:=i;
                       end;
If r<=n div r
 then writeln(r,' ',n div r)
 else writeln(n div r,' ', r);
End.

var a,b,n,i:integer;
begin
readln(n);
a:=i;
b:=n;
for i:=1 to n do
if n mod i = 0 then
if  i<=(n div i) then
begin
a:=i;
b:= n div i;
end;
writeln(a,' ', b);
end.

   const eps=0.00000001;  besk=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var time1,ttime,time2,nap,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;
    dist,xmin,xmax,ymin,ymax,napx,napy,time,pp,jj,step, k,t1,ii,i,tt,j:longint;
     aa,bb,cc:double;
     x,y,aold,b,a:array[-10..2000000] of int64;
     dda:array[-10..1200,-10..1200] of int64;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }

     read(n);  ot:=1000000000;
     for i:=1 to n do  if n mod i=0 then
       begin
          j:=n div i;
          if i<=j then ot:=min(ot,abs(i-j));
          if ot=abs(i-j) then begin ii:=i;jj:=j; end;

       end;
      writeln(jj,' ',ii);

   1:          close(output);
end.

var i,a,minn,n:integer;
    begin
    readln(n);
    minn:= n;
    for i:=1 to n do
    begin
        if (n mod i = 0)then
        begin
            if ((abs(i  - n div i )< minn) and (i <= n div i) )
            then
            begin
                a:=i;
                minn := (abs(i  - n div i ));
            end;
        end;
    end;
    writeln(a,' ',n div a);
    end.

var
i,k:integer;
n:real;
begin
read(n);
k:=round(n);
for i:=round(sqrt(n)) downto 1 do
if k mod i = 0 then
begin
writeln (i,' ', k div i);
break;
end;
end.

var n,i:LongInt;
Begin
 read(n);
 for i:= trunc(sqrt(n)) DownTo 1 do
  begin
   if n mod i=0
    then begin
          write(i,' ',n div i);
          Exit;
         end;
  end;
End.

Program DisplaySize;
uses math;
var n,i,a,b:longint;
begin   //assign(input,'747A.inp'); reset(input);
        //assign(output,'747A.out'); rewrite(output);
        readln(n);
        for i:=1 to trunc(sqrt(n)) do
        begin   if n mod i=0 then
                begin   a:=i;
                        b:=n div i;
                end;
        end;
        write(a,#32,b);
        //close(input); close(output);
end.

  var N,A,i,j,min,ans: int64;
   b:integer;

   begin

   readln(N);
   min:=10000000000;

   for b:=1 to N do
    if n mod b=0 then
     if (b-(n div b)<min) and (b-(n div b)>=0) then
     begin
     min:=b-(n div b);
     ans:=b;
     end;

     writeln(N div ans,' ',ans);

   end.

Program con747z1;
Var
    d:longint;
    i,n:longint;
Begin
    //assign(input,'input.txt'); reset(input);
    //assign(output,'output.txt'); rewrite(output);

        read(n); i:=round(sqrt(n))+1; d:=0;

        while (i>1) do Begin

                if (n mod i = 0) then Begin
                     d:=i;
                     break;
                End;

                dec(i);

        End;

        if (d = 0) then write(1,' ',n) else
                if (d>n div d) then write(n div d,' ',d) else write(d,' ',n div d);

    //close(input); close(output);
End.

var a,b,n,min,i:longint;
begin
  readln(n);
  a:=1; b:=n;
  i:=1;
  while b>a do
    begin
      inc(i);
      if n mod i=0 then
        begin
          b:=n div i;
          a:=n div b;
        end;
    end;
  writeln(b,' ',a);
end.

Const Finp='';
      Fout='';
Var n,a,b:longint;

Procedure Nhap;
Var f:Text;
Begin
    assign(f,finp); reset(f);
    read(f,n);
    close(f);
End;
Procedure Solve;
Var i,diff:longint;
Begin
    diff:=maxlongint;
    for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
            if (n div i)-i<diff then
                begin
                    a:=i; b:=(n div i);
                    diff:=b-a;
                end;
End;
Procedure Xuat;
Var f:Text;
Begin
    assign(f,fout); rewrite(f);
    write(f,a,' ',b);
    close(f);
End;

Begin
    Nhap;
    Solve;
    Xuat;
End.

program zzz;
  var
    n,a,b:integer;
begin
  readln(n);
  a:=trunc(sqrt(n));
  while n mod a<>0 do dec(a);
  b:=n div a;
  writeln(a,' ',b);
end.

var x,i:longint;
begin
 read(x);
 for i:=round(sqrt(x)) downto 1 do
  if x mod i =0
   then begin write(i,' ',x div i);halt;end;
end.

var a,b,i,n : longint;
begin
  readln(n);
  for i:=1 to trunc(sqrt(n)) do begin
      if n mod i = 0 then begin a:=i; b:=n div i; end;
    end;
  writeln(a,' ',b);
end.

{$R-,Q-,S-,I-}
{$OPTIMIZATION LEVEL2}
{$INLINE ON}

uses math;

procedure mofile;
begin
        {$IFDEF ONLINE_JUDGE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ELSE}
        assign(input,'checking.inp');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ENDIF}
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

const
        maxc=1000000000+69;
        modulo=1000000000+7;

type
        re=record
                x,y:longint;
        end;

var
        n,i:longint;

procedure xuli;
var
        i:longint;
begin
        readln(n);
        for i:=trunc(sqrt(n)) downto 1 do
        begin
                if n mod i=0 then
                begin
                        writeln(i,' ',n div i);
                        halt;
                end;
        end;
end;

begin
        //mofile;
        xuli;
        dongfile;
end.

var
 a,i:longint;
begin
 readln(a);
 for i:=trunc(sqrt(a)) downto 1 do if a mod i=0 then
 begin
  writeln(i,' ',a div i);
  halt;
 end;
end.

var
	n: longint;
	a, b: longint;
procedure giai;
var i: longint;
begin
	for i:=1 to trunc(sqrt(n)) do
		if n mod i = 0 then
		begin
			a:= i;
			b:= n div i;
		end;
	writeln(a,#32,b);
end;

begin
	readln(n);
	giai;
end.

var
i,n:integer;
begin
read(n);
for i:=round(sqrt(n)) downto 1 do
if n mod i = 0 then
begin
writeln (i,' ', n div i);
break;
end;
end.

var n,a,b:longint;
        x:real;
begin
//assign(input,'baiA.inp');reset(input);
//assign(output,'baiA.out');rewrite(output);
readln(n);
b:=trunc(sqrt(n));
if n mod b = 0 then writeln(b,' ',n div b)
else begin
while n mod b <> 0 do
        inc(b);
writeln(n div b,' ',b); end;

{if x=trunc(x) then writeln(x,' ',x)
else
        begin
        b:=trunc(x)+1;
        a:=n div b;
        writeln(a,' ',b);
        end; }
end.

var
 a,m,j,i,n,g : longint;
begin
 readln(n);
 for i:= trunc(sqrt(n)) downto 1 do
  begin
   if n mod i = 0 then
    begin
     writeln(i,' ',n div i);
     break;
    end;
  end;
end.

var n,k:longint;
begin
readln(n);
k:=trunc(sqrt(n));
while n mod k>0 do k:=k-1;
write(k,' ',n div k);
end.

var n,i,x:LongInt;
begin
readln(n);
for i:=1 to round(sqrt(n)) do
        begin
        if n mod i=0 then
                x:=i;
        end;
writeln(x,' ',n div x);
end.

var n, i: longword;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
    if (n mod i)=0 then
      begin
        writeln(i, ' ', n div i); break;
      end;
end.

Const fi='';
      fo='';

Var n:longint;
    a,b:longint;
    f:text;

Procedure Enter;
Begin
        Assign(f,fi);reset(f);
        Readln(f,n);
        Close(f);
End;

Procedure Run;
Var t,i:longint;
Begin
        t:=trunc(sqrt(n));
        For i:=1 to t do
        If (n mod i)=0 then
        Begin
                a:=i;
                b:=n div i;
        End;
End;

Procedure Print;
Begin
        Assign(f,fo);rewrite(f);
        Writeln(f,a,' ',b);
        Close(f);
End;

BEGIN
        Enter;
        Run;
        Print;
END.

uses math;
var
  n,x,y,mn,i : longint;

begin
  mn:=maxlongint;
  readln(n);
  for i:=1 to n do
    if (n mod i = 0) and (abs(n div i-i) < mn) then begin
      mn:=abs(n div i-i);
      x:=i;
      y:=n div i;
    end;
  writeln(min(x,y),' ',max(x,y));
end.

uses math;
var n,i,j,k,a,b,a1,b1,m:longint;
    abc:array[1..10000] of longint;
begin
read(n);
for i:=round(sqrt(n))+1 downto 1 do
if j>4 then break else
if n/i-trunc(n/i)=0 then begin
                         inc(j);
                         abc[j]:=i;
                         end;
m:=100000000;
for i:=1 to 3 do
if abc[i]<>0 then if abs(abc[i]-n div abc[i])<m then begin a1:=abc[i]; b1:=n div a1; m:=abs(abc[i]-n div abc[i]); end;
write(min(a1,b1),' ',max(a1,b1));
end.

var
y,u,i,j,o,p,l:integer;
begin
readln(y);

for i:=round(sqrt(y)) downto 1 do begin
 for j:=round(sqrt(y)) to y do
  if i*j=y then begin u:=i; p:=j; l:=1; break; end;
  if l=1 then break;
  end;

writeln(u,' ',p);

end.

Var i,a,b,N:Longint;
 Begin
     Read(N); a:=1; b:=N;
     For i:=1 to Trunc(Sqrt(N)) do
      If N mod i = 0 then
       If N div i >= i then
        If N div i - i < b - a then
         Begin
             a:=i;
             b:=N div i;
         End;
     Write(a,' ',b);
 End.

var
i,j,c,d,e,b,n:longint;
begin
read(n);
if trunc(sqrt(n))=sqrt(n) then begin writeln(trunc(sqrt(n)),' ',trunc(sqrt(n)));exit;end;
for i:=trunc(sqrt(n)) downto 1 do
begin
if n mod i=0 then begin writeln(i,' ',n div i);exit;
end;
end;
end.

program z1;
var a,b,c,d,i,j,k,l,m,n:longint;
begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n);
for i:=1 to round(sqrt(n)) do
 if n mod i=0 then a:=i;
writeln(a,' ',n div a);
end.

procedure main();
var
   n,row,col:longint;
begin
   read(n);
   for row := trunc(sqrt(n)) downto 1 do
   begin
      if n mod row = 0 then
      begin
         col := n div row;
         break;
      end;
   end;
   write(row,' ',col);
end;

begin
   main();
end.

var
 i,j,n,x,y,t:longint;
begin
 read(n);
 for i:=trunc(sqrt(n)) downto 1 do
 begin
  j:=n div i;
  if (i*j=n) then begin x:=i;y:=j;break;end;
 end;
 if (x>y) then begin t:=x;x:=y;y:=t;end;
 writeln(x,' ',y);
end.

var
 n,i,j,min,x,y:longint;
begin
 read(n);
 min:=maxlongint;
 for i:=1 to n do
  begin
   j:=n div i;
   if (i*j=n) and (i<=j) then
    begin
     if j-i<min then begin min:=j-i;x:=i;y:=j;end;
    end;
  end;
 write(x,' ',y);
end.

const fi='DISPLAY.inp'; fo='DISPLAY.out';
var m,n,a,b,i,z:longint;
begin
 //assign(input,fi); reset(input);
 //assign(output,fo); rewrite(output);
 readln(n);
 m:=1000;
 z:=trunc(sqrt(n));
 if z<m then m:=z;
 For i:=1 to m do
    begin
       if n mod i=0 then
          begin
             a:=i;
             b:=n div i;
          end;
    end;
 writeln(a,' ',b);
end.

Program z1;
var
    n:integer;
    a,b:integer;
    x,y:integer;
    i:integer;
    min:integer;
begin
    read(n);
    min:=maxInt;
    for i:=1 to trunc(sqrt(n)) do begin
          a:=i;
          b:=n div i;
          if (b-a<min)AND(a*b=n)AND(b>=a)AND(b=n/i) then begin
               min:=b-a;
               x:=a;
               y:=b;
          end;
    end;
    write(x,' ',y);
end.

Var a,b,n,i:longint;
    c:real;
    function min(x,y:longint):longint;
    begin
    min:=x;
    if x>y then min:=y;
   end;

    function max(x,y:longint):longint;
    begin
    max:=x;
    if x<y then max:=y;
   end;

    Begin
     read(n);
     c:=sqrt(n);
     if c=trunc(c) then writeln(trunc(c),' ',trunc(c))
      else

        for i:=trunc(c) downto 1 do

          if n mod i=0 then begin writeln(min(i,n div i),' ',max(i,n div i)); exit; end;
      end.

var
 i,j,n,x,y,t:longint;
begin
 readln(n);
 for i:=trunc(sqrt(n)) downto 1 do
  begin
   j:=n div i;
   if (i*j=n) then
    begin
     x:=i;
     y:=j;
     break;
    end;
  end;
 if x>y then
  begin
   t:=x;
   x:=y;
   y:=t;
  end;
 writeln(x,' ',y);
end.

var
n,i:longint;
begin
readln(n);
for i:=trunc(sqrt(n)) downto 1 do
  if n mod i=0 then begin writeln(i,' ',n div i);halt;end;
end.

var
  ans,a,b,i,n,k,j:longint;
  x,y:array[1..111111]of longint;
begin
  read(n);
  i:=2;
  j:=0;
  for i:=1 to n do
  if (n mod i=0) then begin j:=j+1;x[j]:=n div i;y[j]:=i;end;

  ans:=1000000000;
  for i:=1 to j do
  if abs(x[i]-y[i])<ans then begin ans:=abs(x[i]-y[i]);k:=i;end;
  writeln(x[k],' ',y[k]);
end.

var
n,i:longint;
begin
readln(N);
for i:=n div 2 downto 1 do begin
         if n mod i = 0 then begin
            if n div i >=i then begin
                writeln(i,' ',n div i);
                break;
            end;
         end;
end;
end.

var
n,i:longint;
begin
readln(N);
if n=1 then writeln(1)
else begin
for i:=n div 2 downto 1 do begin
         if n mod i = 0 then begin
            if n div i >=i then begin
                writeln(i,' ',n div i);
                break;
            end;
         end;
end;
end;
end.

var t,z,i,n,k: longint;
    a: array [1..1000] of longint;
    b: array [1..300] of longint;
begin
z:=0;
readln (k);
while z*z<k do
      begin
      z:=z+1;
      end;
t:=1;
for i:=1 to z do
    if (k mod i)=0 then
       begin
       a[t]:=i;
       b[t]:=k div i;
       t:=t+1;
       end;
t:=t-1;
writeln (a[t],' ', b[t]);
end.

var t,z,i,n,k: longint;
    a: array [1..1000] of longint;
    b: array [1..300] of longint;
begin
z:=0;
readln (k);
if k=2 then writeln ('1 2') else
if k=1 then writeln ('1 1') else
begin
while z*z<k do
      begin
      z:=z+1;
      end;
t:=1;
for i:=1 to z do
    if (k mod i)=0 then
       begin
       a[t]:=i;
       b[t]:=k div i;
       t:=t+1;
       end;
t:=t-1;
end;
writeln (a[t],' ', b[t]);
end.

var t,z,i,n,k: longint;
    a: array [1..1000] of longint;
    b: array [1..300] of longint;
begin
z:=0;
readln (k);
if k=2 then writeln ('1 2') else
if k=1 then writeln ('1 1') else
begin
while z*z<k do
      begin
      z:=z+1;
      end;
t:=1;
for i:=1 to z do
    if (k mod i)=0 then
       begin
       a[t]:=i;
       b[t]:=k div i;
       t:=t+1;
       end;
t:=t-1;
writeln (a[t],' ', b[t]);
end;
end.

var
 i,j: longint;
 f,sum: array [0..15,0..26] of int64;
 sum1: array [0..15] of int64;
 s: shortstring;
 ans: int64;
begin
 for j:=1 to 26 do
 begin
  f[1,j]:=1;
  sum[1,j]:=sum[1,j-1]+f[1,j];
 end;

 for i:=2 to 15 do for j:=i to 26 do
 begin
  f[i,j]:=sum[i-1,j-1];
  sum[i,j]:=sum[i,j-1]+f[i,j];
 end;

 for i:=1 to 15 do sum1[i]:=sum1[i-1]+sum[i,26];

 while not eof do
 begin
  readln(s);
  ans:=0;
  for i:=1 to length(s)-1 do
  begin
//   ans:=sum[i,26];
   if s[i] >= s[i+1] then break;
  end;

  if length(s) <> 1 then if s[i] >= s[i+1] then begin writeln(0); continue; end;

  for i:=length(s) downto 1 do ans:=ans+sum1[i-1]+sum[i,ord(s[i])-96];

  writeln(ans);
 end;
end.

{ for i:=1 to 5 do
 begin
  for j:=1 to 26 do write(f[i,j],' ');
  writeln;
 end;

 for i:=6 to 6 do
 begin
  for j:=1 to 26 do write(sum[i,j],' ');
  writeln;
 end;}

end.

var a, d, e, i: longint;
b, f, c: real;
begin
read(a);
c:=a;
for i:=1 to a do
begin
if a mod i=0 then
begin
b:=a/i;
if ((i-b<c) or (i-b=c)) and ((i-b>0) or (i-b=0)) then
begin
c:=i-b;
e:=i;
f:=b;
end;
end;
end;
writeln(f,' ',e);
end.

var
    n, i, min, am, bm, a, b : longint;
begin
    readln(n);
    min := 99999;
    for i := 1 to trunc(sqrt(n)) do begin
        if (i * trunc(n div i) = n) and (i <= trunc(n div i)) then begin
            //write(i, ' ', trunc(n div i));
            a := i;
            b := trunc(n div i);
            //writeln(abs(a- b));
            if (abs(a - b) < min) then begin
                min := abs(a-b);
                am := a;
                bm := b;
            end;
        end;
    end;
    write(am, ' ', bm);
end.

Var i , n , tmp , Ans : Longint;

Begin
    tmp := High(Longint);
    Readln(n);
    For i := 1 to Trunc(Sqrt(n)) do
        If (n mod i = 0) then
            If (n div i) - i < tmp then
                Begin Ans := i; tmp := (n div i) - i; End;
    Write(i , ' ' , n div i);
End.

var n,i: integer;
    a,b: real;
begin
 readln(n);
 i:=0;
 while a*b<>n do begin
  a:=(-i+sqrt(i*i+4*n))/2;
  if (frac(a)=0) then b:=a+i;
  i:=i+1;
 end;
 write(a,' ',b);
end.

var n,max,i,r:integer;
begin
readln(n);
max:=1000001;
For i:=1 to n do
 If n mod i = 0 then
                 If abs(i-(n div i))<max
                  then begin
                        max:=abs(i-(n div i));
                        r:=i;
                       end;
If r>=n div r
 then writeln(r,' ',n div r)
 else writeln(n div r,' ', r);
End.

var n,i:LongInt;
Begin
 read(n);
 for i:= trunc(sqrt(n)) DownTo 1 do
  begin
   if n mod i=0
    then begin
          write(i,n div i);
          Exit;
         end;
  end;
End.

Program con747z1;
Var
    d:array[1..2] of longint;
    i,n,k:longint;
Begin
    //assign(input,'input.txt'); reset(input);
    //assign(output,'output.txt'); rewrite(output);

        read(n); k:=0; i:=round(sqrt(n));

        if (i*i=n) then write(i,' ',i) else Begin

                inc(i);
                while (i>=1) and (k<2) do Begin
                        if (n mod i = 0) then Begin
                                inc(k);
                                d[k]:=i;
                        End;
                        dec(i);
                End;
                if (k = 1) then write(1,' ',n) else write(d[2],' ',d[1]);
        End;

    //close(input); close(output);
End.

Program con747z1;
Var
    d:longint;
    i,n:longint;
Begin
    //assign(input,'input.txt'); reset(input);
    //assign(output,'output.txt'); rewrite(output);

        read(n); i:=round(sqrt(n))+1; d:=0;

        while (i>1) do Begin

                if (n mod i = 0) then Begin
                     d:=i;
                     break;
                End;

                dec(i);

        End;

        if (d = 0) then write(1,' ',n) else write(n div d,' ',d);

    //close(input); close(output);
End.

var x,i:longint;
begin
 read(x);
 for i:=round(sqrt(x)) downto 1 do
  if x mod i =0
   then begin write(x div i,' ',i);halt;end;
end.

var n,a,b:longint;
        x:real;
begin
//assign(input,'baiA.inp');reset(input);
//assign(output,'baiA.out');rewrite(output);
readln(n);
b:=trunc(sqrt(n));
if n mod b = 0 then inc(b);
while n mod b <> 0 do
        inc(b);
writeln(n div b,' ',b);

{if x=trunc(x) then writeln(x,' ',x)
else
        begin
        b:=trunc(x)+1;
        a:=n div b;
        writeln(a,' ',b);
        end; }
end.

var
y,u,i,o,p,l:integer;
begin
readln(y);

for i:=1 to y do
for o:=1 to y do
begin
if (i*o=y) and (i<o) and ((l<o-i) or (l>0)) then begin
u:=i;
p:=o;
l:=o-i;
end;
end;

writeln(u,' ',p);

end.

var
y,u,i,j,o,p,l:integer;
begin
readln(y);

for i:=trunc(sqrt(y)) downto 1 do begin
 for j:=trunc(sqrt(y)) to y do
  if i*j=y then begin u:=i; p:=j; break; end;
  break;
  end;

writeln(u,' ',p);

end.

var
 n,i,j,min,x,y:longint;
begin
 read(n);
 min:=maxlongint;
 for i:=1 to n div 2 do
  begin
   j:=n div i;
   if (i*j=n) and (i<=j) then
    begin
     if j-i<min then begin min:=j-i;x:=i;y:=j;end;
    end;
  end;
 write(x,' ',y);
end.


program cf750D;
const maxn=35;
      maxt=6;
      movex:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);
      movey:array[0..7] of longint=(1,1,0,-1,-1,-1,0,1);
var map:array[-maxn*maxt..maxn*maxt,-maxn*maxt..maxn*maxt] of boolean;
    vis:array[-maxn*maxt..maxn*maxt,-maxn*maxt..maxn*maxt,0..7,0..maxn] of boolean;
    t:array[0..maxn] of longint;
    n,ans,i:longint;
procedure go(x,y,dir,step:longint);
var i:longint;
begin
  if vis[x,y,dir,step] then exit;
  vis[x,y,dir,step]:=true;
  for i:=1 to t[step] do
  begin
    x:=x+movex[dir];
    y:=y+movey[dir];
    if not map[x,y] then inc(ans);
    map[x,y]:=true;
  end;
  if step<n then
  begin
    go(x,y,(dir+1)mod 8,step+1);
    go(x,y,(dir+7)mod 8,step+1);
  end;
end;
begin
  readln(n);
  for i:=1 to n do read(t[i]);
  fillchar(map,sizeof(map),0);
  fillchar(vis,sizeof(vis),0);
  ans:=0;
  go(0,-1,0,1);//x,y,direction,step
  writeln(ans);
end.

const
  dx:array[0..7]of longint=(-1,-1,0,1,1,1,0,-1);
  dy:array[0..7]of longint=(0,-1,-1,-1,0,1,1,1);
var
  n,l,i,j,k,p,ans:longint;
  t:array[1..30]of longint;
  a:array[0..30,-150..150,-150..150,0..7]of boolean;
  f:array[-150..150,-150..150]of boolean;
begin
  read(n);
  a[0,0,0,0]:=true;
  for i:=1 to n do
    read(t[i]);
  for l:=1 to n do
    for i:=-150 to 150 do
      for j:=-150 to 150 do
        for k:=0 to 7 do
          if a[l-1,i,j,k]
          then begin
                 for p:=1 to t[l] do
                   f[i+dx[k]*p,j+dy[k]*p]:=true;
                 a[l,i+dx[k]*p,j+dy[k]*p,(k+7) mod 8]:=true;
                 a[l,i+dx[k]*p,j+dy[k]*p,(k+1) mod 8]:=true;
               end;
  for i:=-150 to 150 do
    for j:=-150 to 150 do
      if f[i,j] then inc(ans);
  writeln(ans);
end.

const
    maxn=36;
    dx:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);
    dy:array[1..8] of longint=(1,1,0,-1,-1,-1,0,1);
var
	dd:array[0..maxn,-maxn*5..maxn*5,-maxn*5..maxn*5,1..8,0..5] of boolean;
    b:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;
    i,j:longint;
    n,sum,res:longint;
    a:array[0..maxn] of longint;
procedure calc(u,x,y,k,l:longint);
begin
        if u>n then exit;
        if dd[u,x,y,k,l] then exit;
        b[x,y] := true;
        dd[u,x,y,k,l]:=true;
        if l = 1 then
          begin
                calc(u+1, x+dx[k mod 8+1], y+dy[k mod 8+1], k mod 8+1,a[u+1]);
                calc(u+1, x+dx[(k+6) mod 8+1], y+dy[(k+6) mod 8+1],(k+6) mod 8+1, a[u+1]);
                exit;
          end;
        calc(u,x+dx[k],y+dy[k],k,l-1);
end;
begin
    readln(n);
    for i:=1 to n do
    begin
        read(a[i]);
        sum:=sum+a[i];
    end;
    calc(1, 0, 0, 1, a[1]);
    for i:=-sum to sum do
        for j:=-sum to sum do
        	if b[i,j] then inc(res);
    writeln(res);
end.

{$Mode objfpc}

type
  node = record
    x,y,d:integer;
  end;

var
  i,n,j,kq:integer;
  a:array[0..40] of integer;
  fx,fy:array[0..8] of integer;
  top:integer;
  f,e:array[0..8000000] of node;
  pass:array[-200..200,-200..200,1..8] of boolean;
  axx:array[-400..400,-400..400] of boolean;

procedure solve(o:integer);
var i,dem,j,x,y,d,z:integer;
  begin
    fillchar(pass,sizeof(pass),false);
    dem:=0;
    for i:=1 to top do
      begin
        x:=f[i].x; y:=f[i].y; d:=f[i].d;
        for j:=1 to a[o]-1 do
          begin
            axx[x,y]:=true;
            x:=x + fx[d];
            y:=y + fy[d];
          end;
        axx[x,y]:=true;
        z:=d+1;
        if z = 9 then z:=1;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
        z:=d-1;
        if z = 0 then z:=8;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
      end;
    top:=dem;
    f:=e;
    for i:=1 to top do
      f[i]:=e[i];
  end;

begin
  fx[1]:=0; fy[1]:=1;
  fx[2]:=1; fy[2]:=1;
  fx[3]:=1; fy[3]:=0;
  fx[4]:=1; fy[4]:=-1;
  fx[5]:=0; fy[5]:=-1;
  fx[6]:=-1; fy[6]:=-1;
  fx[7]:=-1; fy[7]:=0;
  fx[8]:=-1; fy[8]:=1;
  read(n);
  for i:=1 to n do read(a[i]);
  top:=1;
  f[1].x:=0;
  f[1].y:=0;
  f[1].d:=1;
  for i:=1 to n do
    solve(i);
  for i:=-400 to 400 do
    for j:=-400 to 400 do
      if axx[i,j] then inc(kq);
  write(kq);
end.

const dx:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);
    dy:array[1..8] of longint=(1,1,0,-1,-1,-1,0,1);
var flag,now:array[-200..200,-200..200,1..8] of boolean;
    flag1:array[-200..200,-200..200] of boolean;
    n,i,j,k,ans,x,y:longint;
	t:array[0..200] of longint;
procedure deal(x,y,k,tt:longint);
var i,j,t1,t2,nowx,nowy:longint;
begin
  t1:=tt-1;
  if (t1<=0) then t1:=t1+8;
  t2:=tt+1;
  if (t2>=9) then t2:=t2-8;
  nowx:=x;nowy:=y;
  for i:=1 to t[k] do
  begin
    nowx:=nowx+dx[t1];
    nowy:=nowy+dy[t1];
    flag1[nowx,nowy]:=true;
  end;
  now[nowx,nowy,t1]:=true;
  nowx:=x;nowy:=y;
  for i:=1 to t[k] do
  begin
    nowx:=nowx+dx[t2];
    nowy:=nowy+dy[t2];
    flag1[nowx,nowy]:=true;
  end;
  now[nowx,nowy,t2]:=true;
end;
begin
  readln(n);
  fillchar(t,sizeof(t),0);
  for i:=1 to n do
	read(t[i]);
  readln;
  fillchar(flag,sizeof(flag),false);
  fillchar(flag1,sizeof(flag1),false);
  for i:=1 to t[1] do
    flag1[1,i]:=true;
  flag[1,t[1],1]:=true;
  for i:=2 to n do
  begin
    fillchar(now,sizeof(now),false);
    for x:=-200 to 200 do
	  for y:=-200 to 200 do
		for k:=1 to 8 do
	    if (flag[x,y,k]) then
	      deal(x,y,i,k);
    for x:=-200 to 200 do
	  for y:=-200 to 200 do
		for k:=1 to 8 do
		flag[x,y,k]:=now[x,y,k];
  end;
  ans:=0;
  for x:=-200 to 200 do
	for y:=-200 to 200 do
	  if flag1[x,y] then inc(ans);
  writeln(ans);
end.

const
    gox :   array[0..7] of longint = (+1 , +1 , +0 , -1 , -1 , -1 , +0 , +1) ;
    goy :   array[0..7] of longint = (+0 , +1 , +1 , +1 , +0 , -1 , -1 , -1) ;

var
    n,front,rear       :   longint ;
    a,s       :   array[0..30] of longint ;
    dd  :   array[-200..200,-200..200] of boolean ;
    free    :   array[0..30,-150..150,-150..150,0..7,1..5] of boolean ;

procedure enter ;
    var i,j :   longint ;
    begin

        read(n) ;
        for i := 1 to n do read(a[i]) ;

        for i := n downto 1 do s[i] :=s[i+1] + a[i] ;

    end ;

procedure dfs(i,x,y,t,k :   longint) ;
    var j,cx,cy,new1,new2 :   longint ;
    begin

        if (i > n) then exit ;
        if (free[i][x][y][t][k]) then exit ;

        dd[x][y] := true ;
        free[i][x][y][t][k] := true ;

        if (k > 1) then dfs(i,x+gox[t],y+goy[t],t,k-1)
        else

            begin

                new1 := (t+1) mod 8 ; new2 := (t+7) mod 8 ;

                dfs(i+1,x+gox[new1],y+goy[new1],new1,a[i+1]) ;
                dfs(i+1,x+gox[new2],y+goy[new2],new2,a[i+1]) ;

            end ;

    end ;

procedure main ;
    var i,j,res :   longint ;
    begin

        dfs(1,0,0,0,a[1]) ;

        res := 0 ;

        for i := -150 to 150 do
            for j := -150 to 150 do
                if (dd[i][j]) then inc(res) ;

        writeln(res) ;

    end ;

begin

    //assign(input,'750D.inp') ; reset(input) ;
    //assign(output,'750D.out') ; rewrite(output) ;
    enter ;
    main ;

end.

program d750;

var
  f       : array [-150..150,-149..150] of boolean;
  i, j, n : longint;
  sol     : longint = 0;
  t       : array [0..35] of longint;
  dx      : array [0..7] of longint = (0, 1, 1, 1, 0, -1, -1, -1);
  dy      : array [0..7] of longint = (1, 1, 0, -1, -1, -1, 0, 1);
  dp      : array [-150..150,-149..150,0..35,0..7] of boolean;

procedure dfs(x, y, d, a : integer);
var
  i       : longint;
begin
  if d = n then exit;
  if a > 7 then a := a - 8;
  if a < 0 then a := a + 8;
  if d > 0 then begin
    x := x + dx[a];
    y := y + dy[a];
  end;
  if dp[y, x, d, a] then exit;
  dp[y, x, d, a] := true;
  for i := 0 to t[d]-1 do f[y+i*dy[a], x+i*dx[a]] := true;
  dfs(x+(t[d]-1)*dx[a], y+(t[d]-1)*dy[a], d+1, a+1);
  dfs(x+(t[d]-1)*dx[a], y+(t[d]-1)*dy[a], d+1, a-1);
end;

begin
  readln(n);
  for i := 0 to n-1 do read(t[i]);
  dfs(0, 0, 0, 0);
  for i := -150 to 150 do for j := -149 to 150 do if f[i, j] then inc(sol);
  writeln(sol);
end.

Program Rekurs;
const gr=150;
var need:array[0..1]of array[-gr..gr]of array[-gr..gr]of longint;
    nap:array[0..1]of array[-gr..gr]of array[-gr..gr]of array[0..7]of longint;
    was:array[-gr..gr]of array[-gr..gr]of longint;
    youdid,i,j,u,kol,n:longint;
    l1,l2:byte;
    t:array[1..30]of longint;

Procedure Dodo(i,j,u,t:longint; l1,l2:byte; ww:longint);
var i1,a,j1:longint;

begin
i1:=i;
j1:=j;
for a:=1 to t do
  begin
  if u=0 then begin inc(i1);   end;
  if u=1 then begin inc(j1); inc(i1);  end;
  if u=2 then begin inc(j1);  end;
  if u=3 then begin inc(j1); dec(i1);  end;
  if u=4 then begin dec(i1);  end;
  if u=5 then begin dec(j1); dec(i1);  end;
  if u=6 then begin dec(j1);   end;
  if u=7 then begin dec(j1); inc(i1);  end;
  was[i1][j1]:=1;
  end;
need[l2][i1][j1]:=ww+1;
nap[l2][i1][j1][(u+1) mod 8]:=1;
nap[l2][i1][j1][(u-1+8) mod 8]:=1;
end;

begin
read(n);
for i:=1 to n do
  begin
  read(t[i]);
  end;

youdid:=0;
need[0][0][-1]:=1;
nap[0][0][-1][0]:=1;
//was[0][0]:=1;
l1:=1;
l2:=0;
while youdid<n do
  begin
  inc(youdid);
  l1:=l1 xor 1;
  l2:=l2 xor 1;

  for i:=-gr to gr do
    for j:=-gr to gr do
      begin
      for u:=0 to 7 do
        begin
        if (need[l1][i][j]=youdid) and (nap[l1][i][j][u]=1) then
          begin
          Dodo(i,j,u,t[youdid],l1,l2,youdid);
          nap[l1][i][j][u]:=0;
          end;
        end;
      end;
  end;

for i:=-gr to gr do
   for j:=-gr to gr do
     if was[i][j]=1 then inc(kol);
writeln(kol);

end.

var i,j,na,n,x,ans:longint;
    na1,na2:array[-151..151,-151..151,1..8]of longint;
    color:array[-151..151,-151..151]of longint;
procedure shift(x:longint);
 var q,i,j:longint;
begin
 for i:=-151 to 151 do
  for j:=-151 to 151 do
   begin
         if Na1[i,j,1]=1
       then begin

             for q:=0 to x-1 do
              color[i,j+q]:=1;
             na2[i-1,j+x,8]:=1;
             na2[i+1,j+x,2]:=1;
            end;
      if Na1[i,j,2]=1
       then begin
             for q:=0 to x-1 do
              color[i+q,j+q]:=1;
             na2[i+x,j+x-1,3]:=1;
             na2[i+x-1,j+x,1]:=1;
            end;
      if Na1[i,j,3]=1
       then begin
             for q:=0 to x-1 do
              color[i+q,j]:=1;
             na2[i+x,j+1,2]:=1;
             na2[i+x,j-1,4]:=1;
            end;
      if Na1[i,j,4]=1
       then begin
             for q:=0 to x-1 do
              color[i+q,j-q]:=1;
             na2[i+x-1,j-x,5]:=1;
             na2[i+x,j-x+1,3]:=1;
            end;
      if Na1[i,j,5]=1
       then begin
             for q:=0 to x-1 do
              color[i,j-q]:=1;
             na2[i+1,j-x,4]:=1;
             na2[i-1,j-x,6]:=1;
            end;
      if Na1[i,j,6]=1
       then begin
             for q:=0 to x-1 do
              color[i-q,j-q]:=1;
             na2[i-x+1,j-x,5]:=1;
             na2[i-x,j-x+1,7]:=1;
            end;
      if Na1[i,j,7]=1
       then begin
             for q:=0 to x-1 do
              color[i-q,j]:=1;
             na2[i-x,j+1,8]:=1;
             na2[i-x,j-1,6]:=1;
            end;
      if Na1[i,j,8]=1
       then begin
             for q:=0 to x-1 do
              color[i-q,j+q]:=1;
             na2[i-x,j+x-1,7]:=1;
             na2[i-x+1,j+x,1]:=1;
            end;
     end;
 for i:=-151 to 151 do
  for j:=-151 to 151 do
   for Na:=1 to 8 do
   begin
    na1[i,j,na]:=na2[i,j,na];
   end;
 for i:=-151 to 151 do
  for j:=-151 to 151 do
   for Na:=1 to 8 do
    na2[i,j,na]:=0;
end;

begin
 readln(n);
 na1[0,0,7]:=1;
 for i:=1 to n do
  begin
   read(x);
   shift(x);
  end;
 ans:=0;
 for i:=-151 to 151 do
  for j:=-151 to 151 do
   begin
    if color[i,j]=1
     then inc(ans);
   end;
 write(ans);

end.

const INP='';
OUTP='';
DIRX:array[0..7] of longint = (0,1,1,1,0,-1,-1,-1);
DIRY:array[0..7] of longint = (1,1,0,-1,-1,-1,0,1);
var f:text;
a:array[1..30] of longint;
vst:array[-151..151,-151..151,0..7,1..30] of boolean;
v:array[-151..151,-151..151] of boolean;
n,i,kq:longint;
procedure nhap;
begin
assign(f,INP);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
fillchar(vst,sizeof(vst),false);
fillchar(v,sizeof(v),false);
end;
procedure xuLi(x,y,d,r:longint);
var i:longint;
begin
if r>n then exit;
if vst[x,y,d,r] then exit;{
for i:=r downto 1 do
if vst[x,y,d,i] then exit; }
//INC(kq);
vst[x,y,d,r]:=true;
for i:=1 to a[r] do
if not v[x+DIRX[d]*i,y+DIRY[d]*i] then
begin
v[x+DIRX[d]*i,y+DIRY[d]*i]:=true;
INC(kq);
end;
//if r=1 then DEC(a[r]);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);
end;
procedure xuat;
begin
assign(f,OUTP);
rewrite(f);
write(f,kq);
close(f);
end;
begin
nhap;
xuLi(0,0,0,1);
xuat;
end.

  const eps=0.00000001;  besk=2000000000000000008;  nn=200000;
   label 1,2,3;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;
    k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;
     aa,bb,cc:double;
     npx,npy:array[-1000..1000] of int64;
     napx,napy:array[-1..30,-100..100] of int64;
     finzan,zan:array[0..31,-1..10,-200..200,-200..200] of boolean;
     kolnap  :array[0..31,-200..200,-200..200] of longint;
     finnap: array[0..31,-1..20,-200..200,-200..200] of byte;
     c,d,x,y,aold,b,a:array[-10..1000002] of int64;
     dda:array[-10..1200,-10..1200] of int64;
   zanx,zany:array[-10..200000] of boolean;
   polog:array[-10..200004, 0..5] of int64;
    zzan:array[-1000..3000,-1000..3000] of boolean;
    ss, ss1,ss2:array[-1000..1000000] of string;
     fl:array[-10000..600000] of boolean;
    sss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       oldflag,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
     readln(n);
     npx[0]:=1;npy[0]:=0;
     npx[1]:=1;npy[1]:=-1;
     npx[2]:=0;npy[2]:=-1;
     npx[3]:=-1;npy[3]:=-1;
     npx[4]:=-1;npy[4]:=0;
     npx[5]:=-1;npy[5]:=1;
     npx[6]:=0;npy[6]:=1;
     npx[7]:=1;npy[7]:=1;
     for i:=0 to 1000 do begin npx[i]:=npx[i mod 8];npy[i]:=npy[i mod 8]; end;
     for i:=1 to 1000 do begin npx[i-1000]:=npx[i]; npy[i-1000]:=npy[i]; end;

   { for i:=-20 to 20 do writeln(i,' ',npx[i],' ',npy[i]);
    }

    for i:=1 to n do read(a[i]);

    zan[0,0,0,0]:=true;
    for step:=1 to n do
      begin
         for i:=-200 to 200 do for j:=-200 to 200 do for k:=0 to 7 do
         if zan[step-1,k,i,j] then
           begin
                begin
                   dx:=npx[k];
                   dy:=npy[k];

                   for ii:=1 to a[step] do
                   zzan[i+ii*dx,j+ii*dy]:=true;
                   zan[step,(k+7) mod 8,i+dx*a[step],j+dy*a[step]]:=true;
                   zan[step,(k+1) mod 8,i+dx*a[step],j+dy*a[step]]:=true;

                end;
           end;

      end;
        ot:=0;

      for i:=-1000 to 1000 do for j:=-1000 to 1000 do  if zzan[i,j] then
     begin
       inc(ot);
       {writeln(i,' ',j);  }
     end;
       writeln(ot);

   1:          close(output);
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='d';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qc:array[0..30,0..300,0..300,0..7]of shortint;
    rr:array[0..300,0..300]of  shortint;
    dir:array[0..7,0..1]of shortint;
    qq:array[0..30]of shortint;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    dd,dx,dy,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;
    nn,mm,kk,u,v,res,cur,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  dir[0,0]:=0; dir[0,1]:=1;
  dir[1,0]:=1; dir[1,1]:=1;
  dir[2,0]:=1; dir[2,1]:=0;
  dir[3,0]:=1; dir[3,1]:=-1;
  dir[4,0]:=0; dir[4,1]:=-1;
  dir[5,0]:=-1; dir[5,1]:=-1;
  dir[6,0]:=-1; dir[6,1]:=0;
  dir[7,0]:=-1; dir[7,1]:=1;
  read(n);
  for k:=1 to n do read(qq[k]);
  fillchar(qc,sizeof(qc),0);
  fillchar(rr,sizeof(rr),0);
  dec(qq[1]);
  qc[0,150,150,0]:=1;
  qc[1,150,150+qq[1],0]:=1;
  rr[150,150]:=1;
  for k:=1 to qq[1] do rr[150,150+k]:=1;
  for k:=2 to n do
    begin
    for i:=0 to 300 do
      for j:=0 to 300 do
        for dd:=0 to 7 do
              if qc[k-1,i,j,dd]=1 then
                begin
                dx:=dd-1;
                dy:=dd+1;
                if dx<0 then dx:=7;
                if dy>7 then dy:=0;
                for t:=1 to qq[k] do
                  begin
                  rr[i+dir[dx,0]*t,j+dir[dx,1]*t]:=1;
                  rr[i+dir[dy,0]*t,j+dir[dy,1]*t]:=1;
                  end;
                qc[k,i+dir[dx,0]*qq[k],j+dir[dx,1]*qq[k],dx]:=1;
                qc[k,i+dir[dy,0]*qq[k],j+dir[dy,1]*qq[k],dy]:=1;
                end;
    end;
  res:=0;
  for i:=0 to 300 do
    begin
    for j:=0 to 300 do
      if rr[i,j]>0 then
        begin
        //write('#');
        inc(res);
        end
        //else write('.');
    //writeln;
    end;
  writeln(res);

  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

const
    maxn	=	35;
    dx 		: 	array[1..8] of longint = (0, 1, 1, 1, 0, -1, -1, -1);
    dy		:	array[1..8] of longint = (1, 1, 0, -1, -1, -1, 0, 1);

var
    i, j: longint;
    n, s, ans: longint;
    a:array[0..maxn] of longint;
    vis:array[0..maxn, -maxn*5..maxn*5, -maxn*5..maxn*5, 1..8, 0..5] of boolean;
    choose:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;

procedure calc(i, x, y, k, l:longint);
begin
        if i > n then exit;
        if vis[i, x, y, k, l] then exit;
        choose[x, y] := true;
        vis[i, x, y, k, l]:=true;

        if l = 1 then
          begin
                calc(i + 1, x + dx[k mod 8 + 1], y + dy[k mod 8 + 1], k mod 8 + 1,a[i + 1]);
                calc(i + 1, x + dx[(k + 6) mod 8 + 1], y + dy[(k + 6) mod 8 + 1],(k + 6) mod 8 + 1, a[i + 1]);
                exit;
          end;

        calc(i,x+dx[k],y+dy[k],k,l-1);
end;

procedure print;
 	begin
 	    for i := -s to s do
        	for j := -s to s do
        		if choose[i, j] then inc(ans);

        writeln(ans);
 	end;

begin
    //assign(input, 'in.txt');
    //reset(input);

    readln(n);
    for i:=1 to n do
    begin
        read(a[i]);
        s := s + a[i];
    end;
    //writeln(s);
    calc(1, 0, 0, 1, a[1]);
    print;
    //close(input);
end.

{$IFDEF ONLINE_JUDGE}
{$R-,Q-,S-,I-}
{$OPTIMIZATION LEVEL2}
{$INLINE ON}
{$ENDIF}

uses math;

procedure mofile;
begin
        {$IFDEF ONLINE_JUDGE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ELSE}
        assign(input,'checking.inp');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ENDIF}
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

const
        maxc=1000000000+69;
        modulo=1000000000+7;
        maxn=30+2;
        dx:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);
        dy:array[1..8] of longint=(1,1,0,-1,-1,-1,0,1);

type
        re=record
                x,y:longint;
        end;

var
        n,sum,res:longint;
        a:array[0..maxn] of longint;
        kt:array[0..maxn,-maxn*5..maxn*5,-maxn*5..maxn*5,1..8,0..5] of boolean;
        chon:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;

procedure dfs(i,x,y,k,l:longint);
begin
        if i>n then exit;
        if kt[i,x,y,k,l] then exit;
        kt[i,x,y,k,l]:=true;
        chon[x,y]:=true;
        if l=1 then
        begin
                dfs(i+1,x+dx[k mod 8+1],y+dy[k mod 8+1],k mod 8+1,a[i+1]);
                dfs(i+1,x+dx[(k+6) mod 8+1],y+dy[(k+6) mod 8+1],(k+6) mod 8+1,a[i+1])
        end
        else dfs(i,x+dx[k],y+dy[k],k,l-1);
end;

procedure xuli;
var
        i,j:longint;
begin
        readln(n);
        for i:=1 to n do
        begin
                read(a[i]);
                sum:=sum+a[i];
        end;

        dfs(1,0,0,1,a[1]);
        for i:=-sum to sum do
        for j:=-sum to sum do
        if chon[i,j] then inc(res);

        writeln(Res);
end;

begin
        mofile;
        xuli;
        dongfile;
end.

{$OPTIMIZATION LEVEL2}
{$INLINE ON}
uses math;
const log=18;
      ms=1e-9;
      oo=round(1e9);
      modulo=1000000007;
      fi='';
      fo='';
      maxn=31;
      maxm=152;
      move:array[0..7,1..2]of longint=((1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1));

var f1,f2:text;
    a:array[-152..152,-152..152]of longint;
    f:array[0..maxn,-152..152,-152..152,0..8]of longint;
    n:longint;
    re:array[0..maxn]of longint;

procedure openfile;
 begin
  assign(f1,fi);
  reset(f1);
  assign(f2,fo);
  rewrite(f2);
 end;

procedure closefile;
 begin
  close(f1);
  close(f2);
 end;

procedure input;
 var i:longint;
 begin
  readln(f1,n);
  for i:=1 to n do
   read(f1,re[i]);
 end;

procedure init;
  var i,j:longint;

  begin
   f[1,re[1],0,7]:=1;
   f[1,re[1],0,1]:=1;
   for i:=1 to re[1] do
    a[i,0]:=1;
  end;

procedure solve;
  var i,j,x,y,l,r,k,d:longint;
  begin
   for i:=2 to n do
    begin
     for l:=-maxm to maxm do
      for r:=-maxm to maxm do
       for k:=0 to 7 do
        if f[i-1,l,r,k]=1 then
         begin
          x:=l;y:=r;
          for d:=1 to re[i] do
           begin
            x:=x+move[k,1];
            y:=y+move[k,2];
            a[x,y]:=1;
           end;
          f[i,x,y,(k+7)mod 8]:=1;
          f[i,x,y,(k+1)mod 8]:=1;
         end;
    end;
  end;

procedure output;
  var i,ans,j:longint;
  begin
   ans:=0;
   for i:=-maxm to maxm do
    for j:=-maxm to maxm do
     if a[i,j]=1 then inc(ans);
   writeln(f2,ans);
  end;

begin
 openfile;
 input;
 init;
 solve;
 output;
 closefile;
end.

type
  rec=record
  		x,y,d,t:longint;
  	  end;
const
  dx:array[0..7] of longint=(-1,-1,0,1,1,1,0,-1);
  dy:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);
var
  q:array[0..2000000] of rec;
  vis:array[-150..150,-150..150,0..7,0..150] of boolean;
  occ:array[-200..200,-200..200] of boolean;
  turn:array[0..200] of boolean;
  a:array[0..30] of longint;
  l,r:array[0..7] of longint;
  n,i,j,ans,head,tail,d:longint;
procedure push(x,y,d,t:longint);
  begin
    if (vis[x][y][d][t])or(t>a[n]) then exit;
    vis[x][y][d][t]:=true;
    if not occ[x][y] then
      begin
        occ[x][y]:=true;
        //writeln(x,' ',y);
        inc(ans);
      end;
    q[tail].x:=x;q[tail].y:=y;
    q[tail].d:=d;q[tail].t:=t;
    inc(tail);
  end;
begin
  //writeln((sizeof(vis))/1024/1024:0:8);
  //assign(input,'D.in');reset(input);
  //assign(output,'D.out');rewrite(output);
  read(n);
  for i:=1 to n do read(a[i]);
  for i:=2 to n do inc(a[i],a[i - 1]);
  fillchar(turn,sizeof(turn),false);
  for i:=1 to n do turn[a[i]]:=true;
  fillchar(vis,sizeof(vis),false);
  fillchar(occ,sizeof(occ),false);
  q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;
  vis[0][0][0][1]:=true;occ[0][0]:=true;ans:=1;
  for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;
  for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;
  head:=1;tail:=2;
  while (head<tail) do
    begin
      d:=q[head].d;
      if turn[q[head].t]
        then
          begin
            push(q[head].x + dx[l[d]],q[head].y + dy[l[d]],l[d],q[head].t + 1);
            push(q[head].x + dx[r[d]],q[head].y + dy[r[d]],r[d],q[head].t + 1);
          end
        else push(q[head].x + dx[d],q[head].y + dy[d],d,q[head].t + 1);
      inc(head);
    end;
  writeln(ans);
  {for i:=-10 to 10 do
    begin
      for j:=-10 to 10 do
        if occ[i][j]
          then write('*')
          else write(' ');
      writeln;
    end;}
end.

var
  fk : array[0..50,-200..200,-200..200,0..7] of longint;
  f : array[-200..200,-200..200] of longint;
  a : array[0..50] of longint;
  i,j,n,m,k,xx,x,y,ans,q : longint;
  dx : array[0..7] of longint = (-1,-1,0,1,1,1,0,-1);
  dy : array[0..7] of longint = (0,1,1,1,0,-1,-1,-1);

begin
  readln(n);
  for i:=1 to n do read(a[i]);
  fk[0,0,0,0]:=1;
  for i:=1 to n do
    for x:=-200 to 200 do
      for y:=-200 to 200 do
        for k:=0 to 7 do
          if fk[i-1,x,y,k] = 1 then
            for q:=0 to a[i]-1 do begin
              f[x+dx[k]*q,y+dy[k]*q]:=1;
              if q = a[i]-1 then begin
                xx:=k-1;
                if xx < 0 then xx:=xx+8;
                fk[i,x+dx[k]*q+dx[xx],y+dy[k]*q+dy[xx],xx]:=1;
                xx:=k+1;
                xx:=xx mod 8;
                fk[i,x+dx[k]*q+dx[xx],y+dy[k]*q+dy[xx],xx]:=1;
              end;
            end;
  for i:=-200 to 200 do for j:=-200 to 200 do if f[i,j] = 1 then inc(ans);
  writeln(ans);
end.

const e:array[0..7,1..2] of longint=
((-1,0),(-1,-1),(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,1));
var b:array[0..35,-151..151,-151..151,0..7] of boolean;
f:array[-151..151,-151..151] of boolean;
a:array[0..100] of longint;
i,j,k,t,r,n,s:longint;
begin
//assign(input,'newfl.in');reset(input);
//assign(output,'newfl.out');rewrite(output);
readln(n);
for i:=1 to n do
  read(a[i]);
b[0,0,0,0]:=true;
for i:=1 to n do
  for j:=-150 to 150 do
    for k:=-150 to 150 do
      for t:=0 to 7 do
        if b[i-1,j,k,t] then
          begin
          for r:=1 to a[i] do
            f[j+e[t,1]*r,k+e[t,2]*r]:=true;
          b[i,j+e[t,1]*a[i],k+e[t,2]*a[i],(t+1) mod 8]:=true;
          b[i,j+e[t,1]*a[i],k+e[t,2]*a[i],(t+7) mod 8]:=true;
          end;
for i:=-150 to 150 do
  for j:=-150 to 150 do
    if f[i,j] then
      s:=s+1;
writeln(s);
close(input);close(output);
end.

program cf750D;
const maxn=35;
      maxt=6;
      movex:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);
      movey:array[0..7] of longint=(1,1,0,-1,-1,-1,0,1);
var map:array[-maxn*maxt..maxn*maxt,-maxn*maxt..maxn*maxt] of boolean;
    vis:array[-maxn*maxt..maxn*maxt,-maxn*maxt..maxn*maxt,0..7] of boolean;
    t:array[0..maxn] of longint;
    n,ans,i:longint;
procedure go(x,y,dir,step:longint);
var i:longint;
begin
  if vis[x,y,dir] then exit;
  vis[x,y,dir]:=true;
  for i:=1 to t[step] do
  begin
    x:=x+movex[dir];
    y:=y+movey[dir];
    if not map[x,y] then inc(ans);
    map[x,y]:=true;
  end;
  if step<n then
  begin
    go(x,y,(dir+1)mod 8,step+1);
    go(x,y,(dir+7)mod 8,step+1);
  end;
end;
begin
  readln(n);
  for i:=1 to n do read(t[i]);
  fillchar(map,sizeof(map),0);
  fillchar(vis,sizeof(vis),0);
  ans:=0;
  go(0,-1,0,1);//x,y,direction,step
  writeln(ans);
end.

const
    maxn	=	35;
    dx 		: 	array[1..8] of longint = (0, 1, 1, 1, 0, -1, -1, -1);
    dy		:	array[1..8] of longint = (1, 1, 0, -1, -1, -1, 0, 1);

var
    i, j: longint;
    n, s, ans: longint;
    a:array[0..maxn] of longint;
    vis:array[0..maxn, -maxn*5..maxn*5, -maxn*5..maxn*5, 1..8, 0..5] of boolean;
    choose:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;

procedure calc(i, x, y, k, l:longint);
begin
        if i > n then exit;
        if vis[i, x, y, k, l] then exit;
        choose[x, y] := true;
        vis[i, x, y, k, l]:=true;

        if l = 1 then
          begin
                calc(i + 1, x + dx[k mod 8 + 1], y + dy[k mod 8 + 1], k mod 8 + 1,a[i + 1]);
                calc(i + 1, x + dx[(k + 6) mod 8 + 1], y + dy[(k + 6) mod 8 + 1],(k + 6) mod 8 + 1, a[i + 1]);
                exit;
          end;

        calc(i,x+dx[k],y+dy[k],k,l-1);
end;

procedure print;
 	begin
 	    for i := -s to s do
        	for j := -s to s do
        		if choose[i, j] then inc(ans);

        writeln(ans);
 	end;

begin
    //assign(input, 'in.txt');
    //reset(input);

    readln(n);
    for i:=1 to n do
    begin
        read(a[i]);
        s := s + a[i];
    end;
    writeln(s);
    calc(1, 0, 0, 1, a[1]);
    print;
    //close(input);
end.

type
  rec=record
  		x,y,d,t:longint;
  	  end;
const
  dx:array[0..7] of longint=(-1,-1,0,1,1,1,0,-1);
  dy:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);
var
  q:array[0..2000000] of rec;
  vis:array[-200..200,-200..200,0..7] of boolean;
  occ:array[-200..200,-200..200] of boolean;
  turn:array[0..200] of boolean;
  a:array[0..30] of longint;
  l,r:array[0..7] of longint;
  n,i,j,ans,head,tail,d:longint;
procedure push(x,y,d,t:longint);
  begin
    if (vis[x][y][d])or(t>a[n]) then exit;
    vis[x][y][d]:=true;
    if not occ[x][y] then
      begin
        occ[x][y]:=true;
        inc(ans);
      end;
    q[tail].x:=x;q[tail].y:=y;
    q[tail].d:=d;q[tail].t:=t;
    inc(tail);
  end;
begin
  //assign(input,'D.in');reset(input);
  //assign(output,'D.out');rewrite(output);
  read(n);
  for i:=1 to n do read(a[i]);
  for i:=2 to n do inc(a[i],a[i - 1]);
  fillchar(turn,sizeof(turn),false);
  for i:=1 to n do turn[a[i]]:=true;
  fillchar(vis,sizeof(vis),false);
  fillchar(occ,sizeof(occ),false);
  q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;
  vis[0][0][0]:=true;occ[0][0]:=true;ans:=1;
  for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;
  for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;
  head:=1;tail:=2;
  while (head<tail) do
    begin
      d:=q[head].d;
      if turn[q[head].t]
        then
          begin
            push(q[head].x + dx[l[d]],q[head].y + dy[l[d]],l[d],q[head].t + 1);
            push(q[head].x + dx[r[d]],q[head].y + dy[r[d]],r[d],q[head].t + 1);
          end
        else push(q[head].x + dx[d],q[head].y + dy[d],d,q[head].t + 1);
      inc(head);
    end;
  writeln(ans);
  {for i:=-15 to 0 do
    begin
      for j:=-10 to 10 do
        if occ[i][j]
          then write(1)
          else write(0);
      writeln;
    end;}
end.

type
  rec=record
  		x,y,d,t:longint;
  	  end;
const
  dx:array[0..7] of longint=(-1,-1,0,1,1,1,0,-1);
  dy:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);
var
  q:array[0..2000000] of rec;
  vis:array[-200..200,-200..200,0..7,0..1] of boolean;
  occ:array[-200..200,-200..200] of boolean;
  turn:array[0..200] of boolean;
  a:array[0..30] of longint;
  l,r:array[0..7] of longint;
  n,i,j,ans,head,tail,d:longint;
procedure push(x,y,d,t:longint);
  begin
    if (vis[x][y][d][ord(turn[t])])or(t>a[n]) then exit;
    vis[x][y][d][ord(turn[t])]:=true;
    if not occ[x][y] then
      begin
        occ[x][y]:=true;
        //writeln(x,' ',y);
        inc(ans);
      end;
    q[tail].x:=x;q[tail].y:=y;
    q[tail].d:=d;q[tail].t:=t;
    inc(tail);
  end;
begin
  //writeln((sizeof(q)+sizeof(vis))/1024/1024:0:8);
  //assign(input,'D.in');reset(input);
  //assign(output,'D.out');rewrite(output);
  read(n);
  for i:=1 to n do read(a[i]);
  for i:=2 to n do inc(a[i],a[i - 1]);
  fillchar(turn,sizeof(turn),false);
  for i:=1 to n do turn[a[i]]:=true;
  fillchar(vis,sizeof(vis),false);
  fillchar(occ,sizeof(occ),false);
  q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;
  vis[0][0][0][ord(turn[1])]:=true;occ[0][0]:=true;ans:=1;
  for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;
  for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;
  head:=1;tail:=2;
  while (head<tail) do
    begin
      d:=q[head].d;
      if turn[q[head].t]
        then
          begin
            push(q[head].x + dx[l[d]],q[head].y + dy[l[d]],l[d],q[head].t + 1);
            push(q[head].x + dx[r[d]],q[head].y + dy[r[d]],r[d],q[head].t + 1);
          end
        else push(q[head].x + dx[d],q[head].y + dy[d],d,q[head].t + 1);
      inc(head);
    end;
  writeln(ans);
  {for i:=-10 to 10 do
    begin
      for j:=-10 to 10 do
        if occ[i][j]
          then write('*')
          else write(' ');
      writeln;
    end;}
end.

{$Mode objfpc}

type
  node = record
    x,y,d:integer;
  end;

var
  i,n,j,kq:integer;
  a:array[0..30] of integer;
  fx,fy:array[0..8] of integer;
  top:integer;
  f,e:array[0..1000000] of node;
  pass:array[-400..400,-400..400,1..8] of boolean;
  axx:array[-400..400,-400..400] of boolean;

procedure solve(o:integer);
var i,dem,j,x,y,d,z:integer;
  begin
    dem:=0;
    for i:=1 to top do
      begin
        x:=f[i].x; y:=f[i].y; d:=f[i].d;
        for j:=1 to a[o]-1 do
          begin
            axx[x,y]:=true;
            x:=x + fx[d];
            y:=y + fy[d];
          end;
        axx[x,y]:=true;
        z:=d+1;
        if z = 9 then z:=1;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
        z:=d-1;
        if z = 0 then z:=8;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
      end;
    top:=dem;
    for i:=1 to top do
      f[i]:=e[i];
  end;

begin
  fx[1]:=0; fy[1]:=1;
  fx[2]:=1; fy[2]:=1;
  fx[3]:=1; fy[3]:=0;
  fx[4]:=1; fy[4]:=-1;
  fx[5]:=0; fy[5]:=-1;
  fx[6]:=-1; fy[6]:=-1;
  fx[7]:=-1; fy[7]:=0;
  fx[8]:=-1; fy[8]:=1;
  read(n);
  for i:=1 to n do read(a[i]);
  top:=1;
  f[1].x:=0;
  f[1].y:=0;
  f[1].d:=1;
  for i:=1 to n do
    solve(i);
  for i:=-400 to 400 do
    for j:=-400 to 400 do
      if axx[i,j] then inc(kq);
  write(kq);
end.

{$Mode objfpc}

type
  node = record
    x,y,d:integer;
  end;

var
  i,n,j,kq:integer;
  a:array[0..30] of integer;
  fx,fy:array[0..8] of integer;
  top:integer;
  f,e:array[0..8000000] of node;
  pass:array[-400..400,-400..400,1..8] of boolean;
  axx:array[-400..400,-400..400] of boolean;

procedure solve(o:integer);
var i,dem,j,x,y,d,z:integer;
  begin
    dem:=0;
    for i:=1 to top do
      begin
        x:=f[i].x; y:=f[i].y; d:=f[i].d;
        for j:=1 to a[o]-1 do
          begin
            axx[x,y]:=true;
            x:=x + fx[d];
            y:=y + fy[d];
          end;
        axx[x,y]:=true;
        z:=d+1;
        if z = 9 then z:=1;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
        z:=d-1;
        if z = 0 then z:=8;
        if not pass[x+fx[z],y+fy[z],z] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z]:=true;
          end;
      end;
    top:=dem;
    for i:=1 to top do
      f[i]:=e[i];
  end;

begin
  fx[1]:=0; fy[1]:=1;
  fx[2]:=1; fy[2]:=1;
  fx[3]:=1; fy[3]:=0;
  fx[4]:=1; fy[4]:=-1;
  fx[5]:=0; fy[5]:=-1;
  fx[6]:=-1; fy[6]:=-1;
  fx[7]:=-1; fy[7]:=0;
  fx[8]:=-1; fy[8]:=1;
  read(n);
  for i:=1 to n do read(a[i]);
  top:=1;
  f[1].x:=0;
  f[1].y:=0;
  f[1].d:=1;
  for i:=1 to n do
    solve(i);
  for i:=-400 to 400 do
    for j:=-400 to 400 do
      if axx[i,j] then inc(kq);
  write(kq);
end.

{$Mode objfpc}

type
  node = record
    x,y,d:integer;
  end;

var
  i,n,j,kq:integer;
  a:array[0..40] of integer;
  fx,fy:array[0..8] of integer;
  top:integer;
  f,e:array[0..8000000] of node;
  pass:array[-400..400,-400..400,1..8,1..5] of boolean;
  axx:array[-400..400,-400..400] of boolean;

procedure solve(o:integer);
var i,dem,j,x,y,d,z:integer;
  begin
    dem:=0;
    for i:=1 to top do
      begin
        x:=f[i].x; y:=f[i].y; d:=f[i].d;
        for j:=1 to a[o]-1 do
          begin
            axx[x,y]:=true;
            x:=x + fx[d];
            y:=y + fy[d];
          end;
        axx[x,y]:=true;
        z:=d+1;
        if z = 9 then z:=1;
        if not pass[x+fx[z],y+fy[z],z,a[o+1]] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z,a[o+1]]:=true;
          end;
        z:=d-1;
        if z = 0 then z:=8;
        if not pass[x+fx[z],y+fy[z],z,a[o+1]] then
          begin
            inc(dem);
            e[dem].x:=x+fx[z];
            e[dem].y:=y+fy[z];
            e[dem].d:=z;
            pass[x+fx[z],y+fy[z],z,a[o+1]]:=true;
          end;
      end;
    top:=dem;
    for i:=1 to top do
      f[i]:=e[i];
  end;

begin
  fx[1]:=0; fy[1]:=1;
  fx[2]:=1; fy[2]:=1;
  fx[3]:=1; fy[3]:=0;
  fx[4]:=1; fy[4]:=-1;
  fx[5]:=0; fy[5]:=-1;
  fx[6]:=-1; fy[6]:=-1;
  fx[7]:=-1; fy[7]:=0;
  fx[8]:=-1; fy[8]:=1;
  read(n);
  for i:=1 to n do read(a[i]);
  top:=1;
  f[1].x:=0;
  f[1].y:=0;
  f[1].d:=1;
  for i:=1 to n do
    solve(i);
  for i:=-400 to 400 do
    for j:=-400 to 400 do
      if axx[i,j] then inc(kq);
  write(kq);
end.

type
    node    =   record
        x,y,t,pos   :   longint ;
    end ;

const
    gox :   array[0..7] of longint = (+1 , +1 , +0 , -1 , -1 , -1 , +0 , +1) ;
    goy :   array[0..7] of longint = (+0 , +1 , +1 , +1 , +0 , -1 , -1 , -1) ;

var
    n,front,rear       :   longint ;
    a       :   array[0..30] of longint ;
    dd  :   array[-150..150,-150..150] of boolean ;
    free    :   array[-150..150,-150..150,0..7,1..5] of boolean ;
    queue   :   array[0..400000] of node ;

procedure enter ;
    var i,j :   longint ;
    begin

        read(n) ;
        for i := 1 to n do read(a[i]) ;

    end ;

procedure push(tx,ty,tt,tp :   longint) ;
    begin

        inc(rear) ;
        queue[rear].x := tx ;
        queue[rear].y := ty ;
        queue[rear].t := tt ;
        queue[rear].pos := tp ;

    end ;

procedure pop(var tx,ty,tt,tp  :   longint) ;
    begin

        tx := queue[front].x ;
        ty := queue[front].y ;
        tt := queue[front].t ;
        tp := queue[front].pos ;
        inc(front) ;

    end ;

procedure bfs ;
    var i,j,u,v,x,y,t,k, newT1 , newT2 , cx , cy , gx , gy    :   longint ;
    begin

        front := 1 ;
        rear := 0 ;
        push(0,0,0,1) ;
        dd[0][0] := true ;
        free[0][0][0][a[1]] := true ;

        while (front <= rear) do
            begin

                pop(x,y,t,k) ;
                free[x][y][t][a[k]] := true ;

                dd[x][y] := true ;

                for i := 1 to a[k]-1 do
                    begin

                        x := x + gox[t] ;
                        y := y + goy[t] ;

                        dd[x][y] := true ;

                    end ;

                newT1 := (t+1) mod 8 ;
                newT2 := (t+7) mod 8 ;

                cx := x + gox[newT1] ; cy := y + goy[newT1] ;
                gx := x + gox[newT2] ; gy := y + goy[newT2] ;

                if (k+1 <= n) and (not free[cx,cy,newT1,a[k+1]]) then
                    begin

                        push(cx,cy,newT1,k+1) ;
                        free[cx][cy][newT1,a[k+1]] := true ;

                    end ;
                if (k+1 <= n) and (not free[gx,gy,newT2,a[k+1]]) then
                    begin

                        push(gx,gy,newT2,k+1) ;
                        free[gx][gy][newT2,a[k+1]] := true ;

                    end ;

            end ;

    end ;

procedure main ;
    var i,j,res :   longint ;
    begin

        bfs ;

        res := 0 ;

        for i := -150 to 150 do
            for j := -150 to 150 do
                if (dd[i][j]) then inc(res) ;

        writeln(res) ;

    end ;

begin

    //assign(input,'750D.inp') ; reset(input) ;
    enter ;
    main ;

end.

type
    node    =   record
        x,y,t,pos   :   longint ;
    end ;

const
    gox :   array[0..7] of longint = (+1 , +1 , +0 , -1 , -1 , -1 , +0 , +1) ;
    goy :   array[0..7] of longint = (+0 , +1 , +1 , +1 , +0 , -1 , -1 , -1) ;

var
    n,front,rear       :   longint ;
    a       :   array[0..30] of longint ;
    dd  :   array[-150..150,-150..150] of boolean ;
    free    :   array[-150..150,-150..150,0..7,1..5] of boolean ;
    queue   :   array[0..400000] of node ;

procedure enter ;
    var i,j :   longint ;
    begin

        read(n) ;
        for i := 1 to n do read(a[i]) ;

    end ;

procedure push(tx,ty,tt,tp :   longint) ;
    begin

        inc(rear) ;
        queue[rear].x := tx ;
        queue[rear].y := ty ;
        queue[rear].t := tt ;
        queue[rear].pos := tp ;

    end ;

procedure pop(var tx,ty,tt,tp  :   longint) ;
    begin

        tx := queue[front].x ;
        ty := queue[front].y ;
        tt := queue[front].t ;
        tp := queue[front].pos ;
        inc(front) ;

    end ;

procedure bfs ;
    var i,j,u,v,x,y,t,k, newT1 , newT2 , cx , cy , gx , gy    :   longint ;
    begin

        front := 1 ;
        rear := 0 ;
        push(0,0,0,1) ;
        dd[0][0] := true ;
        free[0][0][0][a[1]] := true ;

        while (front <= rear) do
            begin

                pop(x,y,t,k) ;
                free[x][y][t][a[k]] := true ;

                dd[x][y] := true ;

                for i := 1 to a[k]-1 do
                    begin

                        x := x + gox[t] ;
                        y := y + goy[t] ;

                        dd[x][y] := true ;

                    end ;

                newT1 := (t+1) mod 8 ;
                newT2 := (t+7) mod 8 ;

                cx := x + gox[newT1] ; cy := y + goy[newT1] ;
                gx := x + gox[newT2] ; gy := y + goy[newT2] ;

                if (k+1 <= n) and (not free[cx,cy,newT1,a[k+1]]) then
                    begin

                        push(cx,cy,newT1,k+1) ;
                        free[cx][cy][newT1][a[k+1]] := true ;

                    end ;
                if (k+1 <= n) and (not free[gx,gy,newT2,a[k+1]]) then
                    begin

                        push(gx,gy,newT2,k+1) ;
                        free[cx][cy][newT2][a[k+1]] := true ;

                    end ;

            end ;

    end ;

procedure main ;
    var i,j,res :   longint ;
    begin

        bfs ;

        res := 0 ;

        for i := -150 to 150 do
            for j := -150 to 150 do
                if (dd[i][j]) then inc(res) ;

        writeln(res) ;

    end ;

begin

    //assign(input,'750D.inp') ; reset(input) ;
    enter ;
    main ;

end.

program d750;

var
  f    : array [-150..150,-149..150] of boolean;
  i, n : longint;
  t    : array [0..39] of longint;

function dfs(x, y, d, a : integer) : integer;
var
  i, c : longint;
begin
  if d = n then begin
    dfs := 0;
    exit;
  end;
  c := 0;
  for i := 0 to t[d]-1 do begin
             if a = 0 then begin
      if f[y+i, x  ] = false then inc(c);
      f[y+i, x  ] := true;
      if i = t[d]-1 then c := c+dfs(x+1, y+i+1, d+1, 1)+dfs(x-1, y+i+1, d+1, 7);
    end else if a = 1 then begin
      if f[y+i, x+i] = false then inc(c);
      f[y+i, x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i, y+i+1, d+1, 0)+dfs(x+i+1, y+i, d+1, 2);
    end else if a = 2 then begin
      if f[y  , x+i] = false then inc(c);
      f[y  , x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i+1, y+1, d+1, 1)+dfs(x+i+1, y-1, d+1, 3);
    end else if a = 3 then begin
      if f[y-i, x+i] = false then inc(c);
      f[y-i, x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i, y-i-1, d+1, 4)+dfs(x+i+1, y-i, d+1, 2);
    end else if a = 4 then begin
      if f[y-i, x  ] = false then inc(c);
      f[y-i, x  ] := true;
      if i = t[d]-1 then c := c+dfs(x-1, y-i-1, d+1, 5)+dfs(x+1, y-i-1, d+1, 4);
    end else if a = 5 then begin
      if f[y-i, x-i] = false then inc(c);
      f[y-i, x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i, y-i-1, d+1, 5)+dfs(x-i-1, y-i, d+1, 6);
    end else if a = 6 then begin
      if f[y  , x-i] = false then inc(c);
      f[y  , x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i-1, y-1, d+1, 5)+dfs(x-i-1, y+1, d+1, 7);
    end else if a = 7 then begin
      if f[y+i, x-i] = false then inc(c);
      f[y+i, x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i-1, y+i, d+1, 6)+dfs(x-i, y+i+1, d+1, 0);
    end;
  end;
  dfs := c;
end;

begin
  readln(n);
  for i := 0 to n-1 do read(t[i]);
  for i := 0 to n-1 do writeln(t[i]);
  writeln(dfs(0, 0, 0, 0));
end.

program d750;

var
  f    : array [-150..150,-149..150] of boolean;
  i, n : longint;
  t    : array [0..39] of longint;

function dfs(x, y, d, a : integer) : integer;
var
  i, c : longint;
begin
  if d = n then begin
    dfs := 0;
    exit;
  end;
  c := 0;
  for i := 0 to t[d]-1 do begin
             if a = 0 then begin
      if f[y+i, x  ] = false then inc(c);
      f[y+i, x  ] := true;
      if i = t[d]-1 then c := c+dfs(x+1, y+i+1, d+1, 1)+dfs(x-1, y+i+1, d+1, 7);
    end else if a = 1 then begin
      if f[y+i, x+i] = false then inc(c);
      f[y+i, x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i, y+i+1, d+1, 0)+dfs(x+i+1, y+i, d+1, 2);
    end else if a = 2 then begin
      if f[y  , x+i] = false then inc(c);
      f[y  , x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i+1, y+1, d+1, 1)+dfs(x+i+1, y-1, d+1, 3);
    end else if a = 3 then begin
      if f[y-i, x+i] = false then inc(c);
      f[y-i, x+i] := true;
      if i = t[d]-1 then c := c+dfs(x+i, y-i-1, d+1, 4)+dfs(x+i+1, y-i, d+1, 2);
    end else if a = 4 then begin
      if f[y-i, x  ] = false then inc(c);
      f[y-i, x  ] := true;
      if i = t[d]-1 then c := c+dfs(x-1, y-i-1, d+1, 5)+dfs(x+1, y-i-1, d+1, 4);
    end else if a = 5 then begin
      if f[y-i, x-i] = false then inc(c);
      f[y-i, x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i, y-i-1, d+1, 5)+dfs(x-i-1, y-i, d+1, 6);
    end else if a = 6 then begin
      if f[y  , x-i] = false then inc(c);
      f[y  , x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i-1, y-1, d+1, 5)+dfs(x-i-1, y+1, d+1, 7);
    end else if a = 7 then begin
      if f[y+i, x-i] = false then inc(c);
      f[y+i, x-i] := true;
      if i = t[d]-1 then c := c+dfs(x-i-1, y+i, d+1, 6)+dfs(x-i, y+i+1, d+1, 0);
    end;
  end;
  dfs := c;
end;

begin
  readln(n);
  for i := 0 to n-1 do read(t[i]);
  writeln(dfs(0, 0, 0, 0));
end.

const INP='';
OUTP='';
DIRX:array[0..7] of longint = (0,1,1,1,0,-1,-1,-1);
DIRY:array[0..7] of longint = (1,1,0,-1,-1,-1,0,1);
var f:text;
a:array[1..30] of longint;
vst:array[-150..150,-150..150,0..7,1..30] of boolean;
v:array[-150..150,-150..150] of boolean;
n,i,kq:longint;
procedure nhap;
begin
assign(f,INP);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
fillchar(vst,sizeof(vst),false);
fillchar(v,sizeof(v),false);
end;
procedure xuLi(x,y,d,r:longint);
var i:longint;
begin
for i:=r downto 1 do
if vst[x,y,d,i] then exit;
if r>n then exit;
//INC(kq);
vst[x,y,d,r]:=true;
for i:=1 to a[r] do
if not v[x+DIRX[d]*i,y+DIRY[d]*i] then
begin
v[x+DIRX[d]*i,y+DIRY[d]*i]:=true;
INC(kq);
end;
if r=1 then DEC(a[r]);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);
end;
procedure xuat;
begin
assign(f,OUTP);
rewrite(f);
write(f,kq);
close(f);
end;
begin
nhap;
xuLi(0,0,0,1);
xuat;
end.

const INP='';
OUTP='';
DIRX:array[0..7] of longint = (0,1,1,1,0,-1,-1,-1);
DIRY:array[0..7] of longint = (1,1,0,-1,-1,-1,0,1);
var f:text;
a:array[1..30] of longint;
vst:array[-150..150,-150..150,0..7,1..30] of boolean;
v:array[-150..150,-150..150] of boolean;
n,i,kq:longint;
procedure nhap;
begin
assign(f,INP);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
fillchar(vst,sizeof(vst),false);
fillchar(v,sizeof(v),false);
end;
procedure xuLi(x,y,d,r:longint);
var i:longint;
begin
if r>n then exit;
if vst[x,y,d,r] then exit;{
for i:=r downto 1 do
if vst[x,y,d,i] then exit; }
//INC(kq);
vst[x,y,d,r]:=true;
for i:=1 to a[r] do
if not v[x+DIRX[d]*i,y+DIRY[d]*i] then
begin
v[x+DIRX[d]*i,y+DIRY[d]*i]:=true;
INC(kq);
end;
if r=1 then DEC(a[r]);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);
xuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);
end;
procedure xuat;
begin
assign(f,OUTP);
rewrite(f);
write(f,kq);
close(f);
end;
begin
nhap;
xuLi(0,0,0,1);
xuat;
end.

  const eps=0.00000001;  besk=2000000000000000008;  nn=200000;
   label 1,2,3;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;
    k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;
     aa,bb,cc:double;
     npx,npy:array[-1000..1000] of int64;
     napx,napy:array[-1..30,-100..100] of int64;
     finzan,zan:array[0..31,-200..200,-200..200] of boolean;
     kolnap  :array[0..31,-200..200,-200..200] of longint;
     finnap: array[0..31,-1..20,-200..200,-200..200] of byte;
     c,d,x,y,aold,b,a:array[-10..1000002] of int64;
     dda:array[-10..1200,-10..1200] of int64;
   zanx,zany:array[-10..200000] of boolean;
   polog:array[-10..200004, 0..5] of int64;
    zzan:array[-1000..3000,-1000..3000] of boolean;
    ss, ss1,ss2:array[-1000..1000000] of string;
     fl:array[-10000..600000] of boolean;
    sss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       oldflag,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
     readln(n);
     npx[0]:=1;npy[0]:=0;
     npx[1]:=1;npy[1]:=-1;
     npx[2]:=0;npy[2]:=-1;
     npx[3]:=-1;npy[3]:=-1;
     npx[4]:=-1;npy[4]:=0;
     npx[5]:=-1;npy[5]:=1;
     npx[6]:=0;npy[6]:=1;
     npx[7]:=1;npy[7]:=1;
     for i:=0 to 1000 do begin npx[i]:=npx[i mod 8];npy[i]:=npy[i mod 8]; end;
     for i:=1 to 1000 do begin npx[i-1000]:=npx[i]; npy[i-1000]:=npy[i]; end;

   { for i:=-20 to 20 do writeln(i,' ',npx[i],' ',npy[i]);
    }

    for i:=1 to n do read(a[i]);
    zan[0,0,0]:=true;
     finzan[0,0,0]:=true;
     finnap[0,0,0,0]:=0;
    napx[0,1]:=0; napy[0,1]:=1; kolnap[0,0,0]:=1;
    for step:=1 to n do
      begin
         for i:=-200 to 200 do for j:=-200 to 200 do
         if finzan[step-1,i,j] then
           begin
              for k:=1 to min(kolnap[step-1,i,j],16) do
                begin
                   dx:=npx[finnap[step-1,k,i,j]];
                   dy:=npy[finnap[step-1,k,i,j]];

                   for ii:=1 to a[step] do
                  begin
                   zan[step,i+dx*ii,j+dy*ii]:=true;
                 {  writeln('zapoln ',i+dx*ii,' -- ',j+dy*ii);
                 } end;

                 finzan[step,i+dx*a[step],j+dy*a[step]]:=true;
                 inc(kolnap[step,i+dx*a[step],j+dy*a[step]]);
                 pp:=kolnap[step,i+dx*a[step],j+dy*a[step]];
                 finnap[step,pp,i+dx*a[step],j+dy*a[step]]:=finnap[step-1,k,i,j]+1;

                 inc(kolnap[step,i+dx*a[step],j+dy*a[step]]);
                 pp:=kolnap[step,i+dx*a[step],j+dy*a[step]];
                 finnap[step,pp,i+dx*a[step],j+dy*a[step]]:=finnap[step-1,k,i,j]-1;

                end;
           end;

      end;
        ot:=0;

            for step:=1 to n do for i:=-200 to 200
      do for j:=-200 to 200 do if zan[step,i,j] then zzan[i,j]:=true;
     ot:=0;
      for i:=-1000 to 1000 do for j:=-1000 to 1000 do  if zzan[i,j] then
     begin
       inc(ot);
       {writeln(i,' ',j);  }
     end;
       writeln(ot);

   1:          close(output);
end.