#include <stdio.h>
#include<malloc.h>


struct Time
{
    int h;  //时
    int m;    //分
    int s;   //秒
};


int main() {
   
   int n,i;
   scanf("%d",&n);
   struct Time * time=(struct Time*)malloc(n*sizeof(struct Time));
   //int *arr=(int *)malloc(n*sizeof(int));

   //赋值
   for(i=0;i<n;i++)
   {
        scanf("%d",&(time+i)->s);
        if(i>0)
          ( time+i)->s+=(time+i-1)->s;
      }

   for(i=0;i<n;i++)
   {
       if((time+i)->s >=60)   //把秒换成分
       {
          (time+i)->h=(time+i)->s/3600;
          (time+i)->m=(time+i)->s/60%60;
          (time+i)->s=(time+i)->s%60;
       }
   }

  //输出
  for(i=0;i<n;i++)
  {
      printf("%d %d %d\n",(time+i)->h,(time+i)->m,(time+i)->s);
  }
}