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