In the array implementation, you declare frontIndex and rearIndex to keep track the position of the front and rear element. They both start at -1. To wrap around so that the frontIndex and rearIndex are within the range of the array length, you use modulo operator %. To enqueue, the formula is rearIndex = (rearIndex + 1) % maxSize. To dequeue, it is frontIndex = (frontIndex + 1) % maxSize.