#include "stdio.h"

#include "stdlib.h"

 

struct grade{

  int score;

  struct grade *next;

};

 

int main()

{

 int score;

 struct grade *head,*p1,*p2;

 scanf("%d",&score);

 p1=(struct grade *)malloc(sizeof(struct grade));

 scanf("%d",&score);

 p1->score=score;

 head=p1;

  p2=p1;

 while(score > 0)

  {

     p1=(struct grade *)malloc(sizeof(struct grade));

    scanf("%d",&score);

    p1->score=score;

    p2->next=p1;

    p2=p1;

  }

 p2->next=NULL;

 free(p1);

 while(head != NULL)

  {

      printf("%d\n",head->score);

      head=head->next;

  }

}