#include <stdio.h>
struct Time{
int h;
int m;
int s;
};
int main() {
int n=0;
scanf("%d",&n);
int arr[10];
for(int i=0;i<n;i++)
scanf("%d",&arr[i]);
struct Time time[10]={0};
for(int i=0;i<n;i++)
{
if(i>0)
{
time[i].h=time[i-1].h;
time[i].m=time[i-1].m;
time[i].s=time[i-1].s;
}
time[i].s+=arr[i];
if(time[i].s>=60)
{
time[i].m+=time[i].s/60;
time[i].s=time[i].s%60;
}
if(time[i].m>=60)
{
time[i].h+=time[i].m/60;
time[i].m=time[i].m%60;
}
printf("%d %d %d\n",time[i].h,time[i].m,time[i].s);
}
return 0;
}