#include<stdio.h>
#include<stdlib.h>
struct node* head;
struct node{
	long long data;
	struct node* next;
};
void insert(long long x)
{
	struct node* temp1=(node*)malloc(sizeof(struct node));
	temp1->data=x;
	struct node* temp2=head;
	if(head==NULL)
	{
		head=temp1;
		head->next=NULL;
	}
	else
	{
		while(temp2->next!=NULL)
		{
			temp2=temp2->next;
		}
		temp1->next=NULL;
		temp2->next=temp1;
	}
}
void print()
{
	struct node* temp=head;
	while(temp!=NULL)
	{
		printf("%lld ",temp->data);
		temp=temp->next;
	}
}
int main()
{
     long long n,i,x;
	 head=NULL;
	 scanf("%lld",&n);
	 for(i=0;i<n;i++)
	 {
	 	scanf("%lld",&x);
        insert(x);
        print();
		 }	
}
