optimize the queue with less amount for the beginning of queue