def smallestRangeI(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    A.sort()
    if A[len(A)-1] - A[0] - 2 * K > 0:
        return A[len(A)-1] - A[0] - 2 * K
    else: 
        return 0

def smallestRangeI2(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    if max(A) - min(A) - 2 * K > 0:
        return max(A) - min(A) - 2 * K
    else: 
        return 0

def smallestRangeI3(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    return max(0, max(A) - min(A) - 2 * K)

print(smallestRangeI3(A = [1,3,6], K = 3))
def smallestRangeI(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    A.sort()
    if A[len(A)-1] - A[0] - 2 * K > 0:
        return A[len(A)-1] - A[0] - 2 * K
    else: 
        return 0

def smallestRangeI2(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    if max(A) - min(A) - 2 * K > 0:
        return max(A) - min(A) - 2 * K
    else: 
        return 0

def smallestRangeI3(A, K):
    """
    :type A: List[int]
    :type K: int
    :rtype: int
    """
    return max(0, max(A) - min(A) - 2 * K)

print(smallestRangeI3(A = [1,3,6], K = 3))
:type A: List[int]     :type K: int     :rtype: int :type A: List[int]     :type K: int     :rtype: int :type A: List[int]     :type K: int     :rtype: int