#include <iostream>
using namespace std;
void swap(int *arr, bool *table, int a, int b) {
int temp = arr[b];
arr[b] = arr[a];
arr[a] = temp;
table[a] = table[b] = true;
}
int main() {
int len;
cin >> len;
if (len < 3 && len > 50000) {
return 0;
}
int *arr = new int[len];
bool *table = new bool[len];
for (int i = 0; i < len; i++) {
cin >> arr[i];
table[i] = false;
}
for (int i = 0; i < len-1; i++) {
int temp = arr[i];
for (int j = i+1; j < len; j++) {
if (arr[j] == temp - 1 && table[i] == false && table[j] == false) {
swap(arr, table, i, j);
}
}
}
for (int i = 0; i < len; i++) {
cout << arr[i]<< " ";
}
cin >> arr[1];
return 0;
}