#include <iostream>
using namespace std;
struct Node {
int data;
Node *next;
};
void append_node(Node **, int);
void list(Node *);
int main(void) {
int i, n, x;
Node *head = NULL;
cin >> n;
for (i = 0; i < n; i++) {
cin >> x;
append_node(&head, x);
}
list(head);
return 0;
}
void append_node(Node **cur, int x) {
Node *new_node = new Node;
new_node->data = x;
new_node->next = NULL;
if (*cur == NULL) {
*cur = new_node;
return;
}
new_node->next = (*cur)->next;
(*cur)->next = new_node;
}
void list(Node *cur) {
if (cur == NULL) return;
while (cur != NULL) {
cout << cur->data << " ";
cur = cur->next;
}
cout << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBOb2RlIHsKICAgIGludCBkYXRhOwogICAgTm9kZSAqbmV4dDsKfTsKCnZvaWQgYXBwZW5kX25vZGUoTm9kZSAqKiwgaW50KTsKdm9pZCBsaXN0KE5vZGUgKik7CgppbnQgbWFpbih2b2lkKSB7CiAgICBpbnQgaSwgbiwgeDsKICAgIE5vZGUgKmhlYWQgPSBOVUxMOwoKICAgIGNpbiA+PiBuOwogICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGNpbiA+PiB4OwogICAgICAgIGFwcGVuZF9ub2RlKCZoZWFkLCB4KTsKICAgIH0KCiAgICBsaXN0KGhlYWQpOwogICAgcmV0dXJuIDA7Cn0KCnZvaWQgYXBwZW5kX25vZGUoTm9kZSAqKmN1ciwgaW50IHgpIHsKICAgIE5vZGUgKm5ld19ub2RlID0gbmV3IE5vZGU7CiAgICBuZXdfbm9kZS0+ZGF0YSA9IHg7CiAgICBuZXdfbm9kZS0+bmV4dCA9IE5VTEw7CgogICAgaWYgKCpjdXIgPT0gTlVMTCkgewogICAgICAgICpjdXIgPSBuZXdfbm9kZTsKICAgICAgICByZXR1cm47CiAgICB9CgogICAgbmV3X25vZGUtPm5leHQgPSAoKmN1ciktPm5leHQ7CiAgICAoKmN1ciktPm5leHQgPSBuZXdfbm9kZTsKfQoKdm9pZCBsaXN0KE5vZGUgKmN1cikgewogICAgaWYgKGN1ciA9PSBOVUxMKSByZXR1cm47CgogICAgd2hpbGUgKGN1ciAhPSBOVUxMKSB7CiAgICAgICAgY291dCA8PCBjdXItPmRhdGEgPDwgIiAiOwogICAgICAgIGN1ciA9IGN1ci0+bmV4dDsKICAgIH0KCiAgICBjb3V0IDw8IGVuZGw7Cn0=