Python 3 || 7 lines,  dp w/list   ||   T/S: 96% / 87%
\nclass Solution:\n    def maxSelectedElements(self, nums: List[int], mx = 1) -> int:\n\n        nums.sort(reverse = True)\n        dp = [0]*(nums[0] + 3)\n\n  
```\nclass Solution:\n    def maxSelectedElements(self, nums: List[int], mx = 1) -> int:\n\n        nums.sort(reverse = True)\n        dp = [0]*(nums[0] + 3)\n\n        for num in nums:\n            dp[num] = 1 + dp[num + 1]\n            dp[num + 1] = 1 + dp[num + 2]\n            mx = max(mx, dp[num], dp[num + 1])\n\n        return mx\n```\n[https://leetcode.com/problems/maximize-consecutive-elements-in-an-array-after-modification/submissions/1181341442/](https://leetcode.com/problems/maximize-consecutive-elements-in-an-array-after-modification/submissions/1181341442/)\n\nI could be wrong, but I think that time complexity is *O*(*N*log*N*) and space complexity is *O*(*M*), in which *N* ~ `len(nums)` and *M* ~ `max(nums)`.
['Python3']