input: Write a function to calculate the minimum and maximum values in an array.
  
  def min_max(array):
      if not array:
          return None, None
      min_val = array[0]
      max_val = array[0]
      for val in array[1:]:
          if val > max_val:
              max_val = val
          if val < min_val:
              min_val = val
      return min_val, max_val
  
  assert min_max([3, 5, 7, 1, 9]) == (1, 9)
  assert min_max([10, 2, 15, 8, 3]) == (2, 15)
  assert min_max([4]) == (4, 4)
  assert min_max([]) == (None, None)
output: def min_max(array):
      if not array:
          return None, None
      min_val = array[0]
      max_val = array[0]
      for val in array[1:]:
          if val > max_val:
              max_val = val
          if val < min_val:
              min_val = val
      return min_val, max_val