#include <cstdio>

long long n, zavrsi, A[1000010], B[20];

void swap(long long &a, long long &b) {
	long long t = a;
	a = b;
	b = t;
}

int main() {

	scanf("%lld", &n);
	for (long long i = 1; i <= n; i++) {
		scanf("%lld", &A[i]);
	}
	for (long long i = 0; i <= 9; i++) {
		B[i] = -1000000000;
	}
	for (long long i = 1; i <= n; i++) {
		B[A[i]] = i;
	}
	for (long long i = 1; i <= n; i++) {
		for (long long j = 9; j > A[i]; j--) {
			if (B[j] > i) {
				swap(A[B[j]], A[i]);
				zavrsi = 1;
			}
			if (zavrsi) break;
		}
		if (zavrsi) break;
	}
	for (long long i = 1; i <= n; i++) {
		printf("%lld ", A[i]);
	}
	printf("\n");
	return 0;
}