#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node* next;
};
struct Node* createNode(int data) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    if (newNode == NULL) {
        printf("Memory allocation failed");
        exit(0);
    }
    newNode->data = data;
    newNode->next = NULL;
    return newNode;
}
void traveseCircularList(struct Node* head) {
    if (head == NULL)
    return;
    struct Node* temp = head;
    do {
        printf("%d ", temp->data);
        temp = temp->next;
    } while (temp != head);
}
int main() {
    int n;
    scanf("%d", &n);
    if (n == 0) {
        printf("Invalid input");
        return 0;
    }
    struct Node *head = NULL, *tail = NULL;
    for(int i=0; i<n; i++) {
        int seatNum;
        scanf("%d", &seatNum);
        struct Node* newNode = createNode(seatNum);
        if (head == NULL) {
            head = newNode;
            tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    tail->next = head;
    traverseCircularList(head);
    return 0;
}