input: from typing import List
  
  def max_consecutive_elements(nums: List[int]) -> int:
      """
      You are provided with a 0-indexed array 'nums' composed of positive integers.
  
      Initially, you can increment the value of any element in the array by at most 1.
  
      After that, you must choose one or more elements from the modified array such that those elements form a consecutive sequence when sorted in ascending order. For instance, the elements [3, 4, 5] are consecutive, while [3, 4, 6] and [1, 1, 2, 3] are not.
  
      Return the highest number of elements that can be selected under these conditions.
  
      Examples:
      >>> nums = [2,1,5,1,1]
      3
      >>> nums = [1,4,7,10]
      1
  
      Constraints:
      1 <= nums.length <= 10^5
      1 <= nums[i] <= 10^6
      """
output:     
      nums.sort()
      max_length = 1
      current_length = 1
  
      for i in range(1, len(nums)):
          if nums[i] == nums[i-1] or nums[i] == nums[i-1] + 1:
              current_length += 1
              max_length = max(max_length, current_length)
          else:
              current_length = 1
  
      return max_length
  