human
Making elements distinct in a sorted array by minimum increments | To find minimum sum of unique elements ..
While current element is same as previous or has become smaller than previous ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to making elements distinct in a sorted array by minimum increments and the other steps required.
 def minSum ( arr , n ) :
	sm = arr [ 0 ]
	for i in range ( 1 , n ) :
		if arr [ i ] == arr [ i - 1 ] :
			j = i
			while j < n and arr [ j ] <= arr [ j - 1 ] :
				arr [ j ] = arr [ j ] + 1
				j += 1
		sm = sm + arr [ i ]
	return sm
arr = [ 2 , 2 , 3 , 5 , 6 ]
n = len ( arr )
print ( minSum ( arr , n ) )