Traverse rest of the input
for ( int i = 1 ; i < arr . Length ; i ++ ) { if ( arr [ i ] == ' I ' ) { al . Add ( min_avail ) ; min_avail ++ ; pos_of_I = i + 1 ; } else { al . Add ( al [ i ] ) ; for ( int j = pos_of_I ; j <= i ; j ++ ) al [ j ] = al [ j ] + 1 ; min_avail ++ ; } }