How do i account for the circular nature of the array?

how to account for the circular nature of array