import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int[] arr = new int[a];
        for(int i = 0; i<a; i++){
            arr[i] = in.nextInt();
        }
        int b = in.nextInt();
        Arrays.sort(arr);
        if(b == 0){
            for(int i = 0; i<arr.length; i++){
                System.out.print(arr[i]+" ");
            }
        }else{
            for(int i = 0; i<arr.length; i++){
                System.out.print(arr[arr.length-i-1]+" ");
            }
        }
    }
}