#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1304
Task: ‘’’
</think>

Write a Python function that takes a list of integers and returns the minimum number of operations needed to make all elements equal, where an operation is defined as adding or subtracti
Generated: 2026-02-13T17:58:42.861149
"""

def min_operations_to_equalize(nums):
    # The minimum number of operations is determined by the median
    nums_sorted = sorted(nums)
    median = nums_sorted[len(nums_sorted) // 2]
    operations = sum(abs(num - median) for num in nums)
    return operations

if __name__ == '__main__':
    test_data = [1, 2, 3, 4, 5]
    result = min_operations_to_equalize(test_data)
    print(f"Minimum operations needed: {result}")