public static int findMinElement(int[] array) {
        int len = array.length;
        if(len == 0) {
            return -1;
        }
        if(len == 1) {
            return array[0];
        }

        int start = 0;
        int end = len - 1;

        while(start < end) {
            int mid = (end+start)/2;
            int leftVal = (mid != 0) ? array[mid-1] : array[len-1];
            int rightVal = array[(mid+1)%len];

            if(array[mid] < leftVal && array[mid] < rightVal) {
                return array[mid];
            } else if(array[mid] > rightVal) {
                return rightVal;
            }

            if(array[mid] > array[end]) {
                start = mid;
            } else if(array[mid] < array[start]) {
                end = mid;
            } else {
                break;
            }
        }

        return array[start];
    }