#include <stdio.h>

int main() {
    int n;
    
    scanf("%d", &n);
    
    if (n < 0) {
        printf("Invalid input");
        return 0;
    }
    
    int stack[20], tempstack[20];
    int top = -1, tempTop = -1;
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &stack[++top]);
    }
    
    
    while(yop != -1) {
        int temp = stack[top--];
        
        while (tempTop != -1 && tempstack[tempTop]> temp) {
            stack[++top] = tempstack[tempTop--];
        }
        
        tempstack[++tempTop] = temp;
    }
    
    for (int i = 0; i <= temp; i++) {
        printf("%d ", tempstack[i]);
    }
    
    return 0;
}