import java.util.*;

public class WorkerShiftUsingDeque {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            // Read number of workers
            if (!sc.hasNextInt()) {
                System.out.println("Invalid input");
                return;
            }
            int N = sc.nextInt();
            if (N < 1 || N > 100) {
                System.out.println("Invalid input");
                return;
            }

            Deque<Integer> workers = new ArrayDeque<>();

            // Read skill levels
            for (int i = 0; i < N; i++) {
                if (!sc.hasNextInt()) {
                    System.out.println("Invalid input");
                    return;
                }
                int skill = sc.nextInt();
                if (skill < 0 || skill > 1000) {
                    System.out.println("Invalid input");
                    return;
                }
                workers.addLast(skill);
            }

            // Read number of shifts
            if (!sc.hasNextInt()) {
                System.out.println("Invalid input");
                return;
            }
            int S = sc.nextInt();
            if (S < 0 || S > 100) {
                System.out.println("Invalid input");
                return;
            }

            // Perform right rotations
            for (int i = 0; i < S; i++) {
                int last = workers.removeLast();
                workers.addFirst(last);
            }

            // Print the final order
            Iterator<Integer> it = workers.iterator();
            while (it.hasNext()) {
                System.out.print(it.next());
                if (it.hasNext()) System.out.print(" ");
            }

        } catch (Exception e) {
            System.out.println("Invalid input");
        } finally {
            sc.close();
        }
    }
}