def minimum_add(nums): st = set(nums) if len(st) == len(nums): return 0 cnt = 0 nums = sorted(nums) for ix in range(1,len(nums)): if nums[ix] == nums[ix-1]: tmp = nums[ix] while tmp+1 in st: tmp += 1 cnt += 1 st.add(tmp+1) cnt += 1 else: continue return cnt