#include<stdio.h>
int A[11000000];
void f(int c, int t){
	if(A[c]==0){
		A[c]=t;
		return;
	}else if(A[c]>t){
		f(c*2,t);
	}else{
		f(c*2+1,t);
	}
}
void g(int c){
	if(A[c]==0) return;
	g(c*2);
	g(c*2+1);
	printf("%d ", A[c]);
}
int main(){
	int n, i, a;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a);
		f(1,a);
	}
	g(1);
}
