a[110],i,b[5000];main(j){for(;*a-~i;)scanf("%d",a-i--);for(;!a[++j]?j=++i<0?:b[i]&&!fflush(!printf("%d %d "+!i*3,b[i]-!!i,b[i])):a[j-1]>a[j]?a[j]^=a[j-1]^=a[j]^=a[b[++*b]=j-1]:1;);}