def remove_duplicates_sorted(A):
    """Remove all duplicates in-place from a sorted array, ruturn the new
    length.

    [LC-0026]

    Examples:

    >>> remove_duplicates_sorted([1, 1, 2])
    2

    >>> remove_duplicates_sorted([0, 0, 1, 1, 1, 2, 2, 3, 3, 4])
    5

    >>> remove_duplicates_sorted([2, 3, 3, 3, 6, 9, 9])
    4

    >>> remove_duplicates_sorted([2, 2, 2, 11])
    2

    """
    read_head = write_head = 0
    prv = None
    while read_head < len(A):
        cur = A[read_head]
        if cur != prv:
            A[write_head] = A[read_head]
            prv = cur
            write_head += 1
        read_head += 1
    return write_head