def is_a(x, n=None):
    """
    Check whether a list is a non-decreasing parking function.

    If a size `n` is specified, checks if a list is a non-decreasing
    parking function of size `n`.

    TESTS::

        sage: from sage.combinat.non_decreasing_parking_function import is_a
        sage: is_a([1,1,2])
        True
        sage: is_a([1,1,4])
        False
        sage: is_a([1,1,3], 3)
        True
    """
    if not isinstance(x, (list, tuple)):
        return False
    prev = 1
    for i, elt in enumerate(x):
        if prev > elt or elt > i + 1:
            return False
        prev = elt
    if n is not None and n != len(x):
        return False
    return True