#include <iostream>
using namespace std;

void replace(int arr[], int start) {
	int max = arr[start], x;
	for (int i = start; i < sizeof(arr); i++) {
		if (arr[i] > max) {
			max = arr[i]; x = i;
		}
	}
	if (arr[0] == max)replace(arr, start + 1);
	else
	{
		arr[x] = arr[start]; arr[start] = max;
	}
}

int main()
{
	int n, * arr;
	cin >> n; arr = new int[n];
	for (int i = 0; i < n; cin >> arr[i], i++);
	if (n == 2) { int a = arr[0]; arr[0] = arr[1]; arr[1] = a; }
	else
	{
		replace(arr, 0);
	}
	for (int i = 0; i < n; cout << arr[i] << ' ', i++);
	return 0;
}