import java.util.*;

public class WorkerShiftUsingDeque {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        try {
            // Read N
            if (!sc.hasNextInt()) {
                System.out.println("Invalid input");
                return;
            }
            int N = sc.nextInt();
            if (N < 1 || N > 100) {
                System.out.println("Invalid input");
                return;
            }

            // Read worker skills
            Deque<Integer> deque = new ArrayDeque<>();
            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;
                }
                deque.addLast(skill);
            }

            // Read S (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 rotations
            S = S % N; // optimize rotations
            for (int i = 0; i < S; i++) {
                int last = deque.removeLast();
                deque.addFirst(last);
            }

            // Print final arrangement
            Iterator<Integer> it = deque.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();
        }
    }
}