#include <stdio.h>
void Razmeni(unsigned long long *a,unsigned long long *b){
	unsigned long long t;
	t=*a;
	*a=*b;
	*b=t;
}
int main(){
	unsigned long long n,a[1000000],j=1,nesto=0;
	scanf("%llu",&n);
	for(int i=0;i<n;i++)scanf("%llu",&a[i]);s
	if(n>2){
		for(int i=0;i<n;i++){
			if(nesto<1){
			if(a[i]<a[i+1]){
				Razmeni(&a[i],&a[i+1]);
				nesto++;
			}
		}
		}
	for(int i=0;i<n;i++)printf("%llu ",a[i]);
	}
	else for(int i=1;i>=0;i--)printf("%llu ",a[i]);
	return 0;
}