const arrLength = readline(); const str = readline(); const sortType = readline(); function func(str, sortType) { let value = str.split(' ').sort((a,b) => { return sortType == '0' ? (a - b) : (b - a); }).join(' '); return value; } print(func(str, sortType));