N = int(input()) L = list(map(int,input().split())) A = sorted(L[:-2]) + L[-2:] print(*A)