Queue constraints

Thanks Desam and Shanti ! Any leads to do this with array operators? instead of foreach?