import java.util.ArrayList;
public class Solution {
    public int minNumberInRotateArray(int [] arr) {
        if (arr == null || arr.length == 0) {
            return -1;
        }
        int n = arr.length;
        int l = 0;
        int r = n - 1;
        int mid = 0;
        while (l < r) {
            mid = l + (r - l) / 2;
            if (arr[l] < arr[r]) {
                return arr[l];
            } 

            if (arr[mid] > arr[r]) {
                l = mid + 1;
            } else if (arr[mid] < arr[r]) {
                r = mid;
            } else {
                r--;
            }
        }
        return arr[l];
    }
}