n=int(input()) l=list(map(int,input().split())) l=sorted(l) l[n-2],l[n-1]=l[n-1],l[n-2] print(*l)