Solve the problem to find the longest circle in an array in O(n).