1 #include<iostream>
2 #include<algorithm>
3 using namespace std;
4 long long int a[1000001];
5 int main()
6 {
7 int n;
8 cin>>n;
9 for(int i=1;i<=n;i++)
10 {
11 cin>>a[i];
12 push_heap(a+1,a+i+1,greater<int>());
13 }
14 int m=n;
15 for(int i=1;i<=n;i++)
16 {
17 int d=a[1];
18 cout<<d<<" ";
19 pop_heap(a+1,a+m+1,greater<int>());
20 m--;
21 }
22 return 0;
23 }