num = 0 A = sorted(A) if len(A) <= len(set(A)): return num else: for i in range(1, len(A)): if A[i] == A[i - 1]: A[i] = A[i] + 1 num = num + 1 return num