#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
vector<int> v;
int x;
while(n--)
{
cin >> x;
v.push_back(x);
}
cin >> x;
if(x==0)
sort(v.begin(),v.end());
else
sort(v.begin(),v.end(),greater<int>());
for(auto i:v)
cout<<i<<" ";
}
}