#include <string>
using namespace std;

// Node structure for doubly linked list
struct Node {
    int data;
    Node* prev;
    Node* next;
    Node(int val) : data(val), prev(NULL), next(NULL) {}
};

class DoublyLinkedList {
public:
    Node* head;
    Node* tail;

    DoublyLinkedList() {
        head = tail = NULL;
    }

    void insert(int val) {
        Node* newNode = new Node(val);
        if (!head) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            newNode->prev = tail;
            tail = newNode;
        }
    }

    void display() {
        Node* temp = head;
        while (temp) {
            cout << temp->data;
            if (temp->next) cout << ",";
            temp = temp->next;
        }
    }
};

// Check if string is a valid integer
bool isInteger(const string& s, long long &val) {
    if (s.empty()) return false;
    stringstream ss(s);
    ss >> val;
    return ss.eof() && !ss.fail();
}

int main() {
    string line;
    int n;

    // Read first line for n
    if (!getline(cin, line) || !isInteger(line, (long long&)n) || n <= 0 || n > 10) {
        cout << "Invalid Input";
        return 0;
    }

    DoublyLinkedList dll;
    for (int i = 0; i < n; i++) {
        long long id;
        if (!getline(cin, line) || !isInteger(line, id) || id < -10000 || id > 10000) {
            cout << "Invalid Input";
            return 0;
        }
        dll.insert((int)id);
    }

    dll.display();
    return 0;
}