Trying to implement rotated sorted array