------
## 最终结论
```python
def delete_and_earn(nums):
    # Step 1: Calculate points for each number
    earn = {}
    for num in nums:
        if num in earn:
            earn[num] += num
        else:
            earn[num] = num

    # Step 2: Initialize dp array
    max_num = max(earn.keys()) if earn else 0
    dp = [0] * (max_num + 1)

    # Step 3: Fill the dp array
    for i in range(1, len(dp)):
        dp[i] = max(dp[i - 1], dp[i - 2] + earn.get(i, 0))

    # Step 4: Return the maximum score
    return dp[max_num]

# Example usage:
nums1 = [3, 4, 2]
print(delete_and_earn(nums1))  # Output: 6

nums2 = [2, 2, 3, 3, 3, 4]
print(delete_and_earn(nums2))  # Output: 9
```