#include <iostream>
using namespace std;

struct Node {
    int data;
    Node* next;
    Node(int val) {
        data = val;
        next = nullptr;
    }
};

void printCircularList(Node* head) {
    if (!head) return;
    Node* temp = head;
    do {
        cout << temp->data << " ";
        temp = temp->next;
    } while (temp != head);
}

int main() {
    int n;
    cin >> n;

    if (n <= 0) {
        cout << "Invalid input" << endl;
        return 0;
    }

    Node* head = nullptr;

    // Reverse order insertion
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        Node* newNode = new Node(val);
        newNode->next = head;
        head = newNode;
    }

    // Make it circular
    Node* tail = head;
    while (tail->next != nullptr)
        tail = tail->next;
    tail->next = head;

    // Insert at beginning
    int valueToInsert;
    cin >> valueToInsert;
    Node* newHead = new Node(valueToInsert);
    newHead->next = head;

    // Fix tail to point to new head
    tail->next = newHead;
    head = newHead;

    // Print list from new head
    printCircularList(head);

    return 0;
}