private int findRightIndex(int[] a, int i, int j, int target) {
        System.out.println("findRightIndex---i:" + i + "; j:" + j);
        int firstNotEqualTargetIndex = a.length;
        while(i < j){
            int middleIndex = (i + j + 1)/2;
            System.out.println("middleIndex:" + middleIndex);
            if(a[middleIndex] == target){
                i = middleIndex;
            } else if(a[middleIndex] > target && a[middleIndex - 1] == target){
                firstNotEqualTargetIndex = middleIndex;
                break;
            } else {
                j = middleIndex;
            }
            if(i == j - 1){
                break;
            }
        }
        
        if(firstNotEqualTargetIndex == a.length && i == j-1){
            if(a[i] == target && a[j] > target){
                firstNotEqualTargetIndex = j;
            }
        }
        return firstNotEqualTargetIndex - 1;
    }