function prime(a:int64):boolean;
var i:longint; res:boolean;
begin
  res:=true;
  i:=2;
  while (sqr(i) <= a) and res do
  begin
    if (a mod i) = 0 then
      res := false;
    inc(i);
  end;
  prime := res;
end;
function digit_sum(a:int64):int64;
var sum:int64;
begin
  sum:=0;
  while a <> 0 do
  begin
    sum := sum + (a mod 10);
    a := a div 10;
  end;
  digit_sum:=sum;
end;
function factor_sum(a:int64):int64;
var i:longint; sum:int64;
begin
  sum := 0;
  i := 2;
  while i <= a do
  begin
    if prime(i) then
      while (a mod i) = 0 do
      begin
        a := a div i;
        sum := sum + digit_sum(i);
      end;
    inc(i);
  end;
  factor_sum := sum;
end;
function smth(a:int64):boolean;
begin
  smth := false;
  if (not(prime(a))) and (digit_sum(a) = factor_sum(a)) then smth := true;
end;
var n,i:longint;num:int64;
begin
  read(n);
  for i := 1 to (n-1) do
  begin
    read(num);
    inc(num);
    while not(smth(num)) do
      inc(num);
    write(num,' ');
  end;
  read(num);
  inc(num);
  while not(smth(num)) do
    inc(num);
  writeln(num);
end.


