len = int(input()) list = list(map(int,input().split())) num = int(input()) for i in range(len): if num < min(list): list.insert(0,num) break elif num > max(list): list.append(num) break elif list[i-1] < num < list[i+1]: list.insert(i+1,num) break for j in list: print(j,end=' ')