Hilbert's Grand Hotel Introduction

Some of you may have heard of Hilbert's Grand Hotel. The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a room number less than their value and if a guest is added to a lower room, all guests in higher rooms with no empty space between them and the new guest are shifted up one room. Can you help him find where each of the guests are staying?

Requirements

Write a program which receives an ordered list of natural numbers as input and places them at their index. If there is already a value in that index, it is shifted up to the next entry in the list. This process repeats until the first empty (0 or undefined) space is found. Any undefined spaces between the current highest index and any new input will be filled by adding 0s. As this is Hilbert's Grand Hotel, rooms higher than the current highest occupied index do not exist.

Input and Output

Input will be an ordered list of natural numbers (allowed to be read through any accepted form of input)
Each number in the input is considered one guest arriving at the hotel and is in order of arrival 

Output will be the final arrangement of guests (numbers)  

Examples


  Input: 1 3 1
  Output: 1 1 3
  Step by step:
  1
  Create room at index 1 and place 1 in it
  1 0 3
  Create rooms up to index 3 and place 3 in room 3
  1 1 3
  Shift the contents of room 1 up one room and place 1 in room 1     
  
  Input: 1 4 3 1 2 1
  Output: 1 1 2 1 3 4
  Step by step:
  1
  Create room at index 1 and place 1 in it
  1 0 0 4
  Create rooms up to index 4 and place 4 in room 4
  1 0 3 4
  Place 3 in room 3
  1 1 3 4
  Shift contents of room 1 up one room and place 1 in room 1
  1 2 1 3 4
  Shift contents of rooms 2 to 4 up one room and place 2 in room 2
  1 1 2 1 3 4
  Shift contents of rooms 1 to 5 up one room and place 1 in room 1  
  
  Input: 10
  Output: 0 0 0 0 0 0 0 0 0 0 10
  Step by step:
  0 0 0 0 0 0 0 0 0 10
  Create rooms up to room 10 and place 10 in room 10
  
  Notes:
  Working with 0 indexed is fine and you may insert a 0 at the front of the output in that case


Standard loopholes are forbidden, shortest code in bytes wins
PHP 93 bytes

for(;$r=$g?$r+1:$g=$argv[++$i];[$g,$h[$r]]=[$h[$r],$g])$h=array_pad($h?:[],$g,0);print_r($h);


0 indexed. Uses a 2 in 1 loop that looks up the next guest after it gets a 0 (or a null form going beyond the current final room). Use like:

php -r "for(;$r=$g?$r+1:$g=$argv[++$i];[$g,$h[$r]]=[$h[$r],$g])$h=array_pad($h?:[],$g,0);print_r($h);" 1 4 3 1 2 1


Ungolfed:

for( $hotel = []; $room = $guest = $argv[ ++$i ]; )
{
    for( $hotel = array_pad( $hotel, $guest, 0 ); $guest; $room++ )
    {
        $last = $hotel[ $room ];
        $hotel[ $room ] = $guest;
        $guest = $last;
    }
}
print_r( $hotel );