program Untitled;
var
   n, c, max, i, j, s : integer;
   a, p : array [ 1..1000 ] of integer;
begin
     readln ( n, c );
     for i := 1 to n do
         read ( a[i] );
     readln;
     for i := 1 to n do
     begin
          for j := 1 to n do
              if a[i] = a[j] then p[i] := p[i] + 1;
     end;
     max := -1;
     while ( s < n ) do
     begin
          for i := 1 to n do
              if p[i] > max then max := p[i];
          i := 0;
          while ( p[i] <> max ) do
                i := i + 1;
          for j := 1 to n do
          begin
              if a[j] = a[i] then
              begin
                   write ( a[j], ' ' );
                   s := s + 1;
                   p[j] := 0;
              end;
          end;
          max := -1;
     end;
readln;
end.
