```
public int searchInsert(int[] A, int target) {
int start = 0;
int end = A.length - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (target - 0.5 < A[mid])
end = mid;
else
start = mid + 1;
}
return A[start] >= target ? start : A.length;
}
```