#include<bits/stdc++.h>
using namespace std;
//-------------循环队列 ——队列的顺序存储结构 ------------
#define MAXQSIZE 100
#define ERROR 0
#define OK 1
typedef int QElemType;
typedef int Status;
typedef struct
{
QElemType *base; //初始化的动态分配存储空间(数组名)
int front; // 头指针(下标)指向队列头元素
int rear; // 尾指针(下标)指向队列尾元素的下一个位置(也就是队列要插入元素的位置)
}SqQueue;
Status InitQueue(SqQueue &Q)
{
Q.base = (QElemType *) malloc(MAXQSIZE * sizeof(QElemType));
if(!Q.base)
exit(OVERFLOW);
Q.front = Q.rear = 0;
return OK;
}
int QueueLength(SqQueue Q)
{
return (Q.rear - Q.front + MAXQSIZE) % MAXQSIZE;
}
Status EnQueue(SqQueue &Q, QElemType e)
{
if((Q.rear + 1) % MAXQSIZE == Q.front)
return ERROR;
Q.base[Q.rear] = e;
Q.rear = (Q.rear + 1) % MAXQSIZE;
return OK;
}
Status DeQueue(SqQueue &Q, QElemType &e)
{
if(Q.front == Q.rear)
return ERROR;
e = Q.base[Q.front];
Q.front = (Q.front+1) % MAXQSIZE;
return OK;
}
bool Empty(SqQueue Q)
{
if(Q.front == Q.rear)
return true;
else
return false;
}
int main()
{
SqQueue Q;
InitQueue(Q);
int n;
cin >> n;
while(n--)
{
int num;
cin >> num;
EnQueue(Q, num);
}
while(!Empty(Q))
{
int num;
DeQueue(Q, num);
cout << num << endl;
}
return 0;
}