Minimum increment and decrement by K of each pair elements required to make all array elements equal | Function to check if its possible to make all array elements equal or not ; Stores the sum of the array ; Traverse the array ; If sum is divisible by N ; Otherwise , not possible to make all array elements equal ; Given array ; Size of the array
def arrayElementEqual ( arr , N ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT sum += arr [ i ] NEW_LINE DEDENT if ( sum % N == 0 ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT arr = [ 1 , 5 , 6 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE arrayElementEqual ( arr , N ) NEW_LINE