input: Write a python function that calculates the minimum operations required to make all elements of an integer array nums divisible by 3. In each operation, you can increment or decrement any element by 1.
  
  Examples:
  >>> nums = [1,2,3,4]
  3
  >>> nums = [3,6,9]
  0
  
  Constraints:
  1 <= nums.length <= 50
  1 <= nums[i] <= 50
output: def min_operations(nums):
      ops = 0
      for num in nums:
          remainder = num % 3
          if remainder != 0:
              ops += min(remainder, 3 - remainder)
      return ops