def main(): # intializing the array arr = [1, 2, 3] # initializing operations count to 0 no_of_operations = 0 flag = 0 # performing the operations on array to make them equal while not are_equal(arr): flag = 1 # finding the maximum from the list maximum = max(arr) # incrementing all the elements except maximum for i in range(len(arr)): if arr[i] != maximum: arr[i] += 1 # incrementing the operations count by 1 no_of_operations += 1 print(no_of_operations) if flag == 0 else print(no_of_operations + 1) # checking whether all the elements are equal or not def are_equal(arr): global no_of_operations for i in range(len(arr) - 1): if arr[i] != arr[i + 1]: return False return True if __name__ == '__main__': main()