enumerate subarrays and keep track of incontinuities
\n\n# Code\n\ndef sumImbalanceNumbers(self, nums: List[int]) -> int:\n    ret = 0\n    for start in range(len(nums)):\n        seen = set([nums[start]])\n      
\n\n# Code\n```\ndef sumImbalanceNumbers(self, nums: List[int]) -> int:\n    ret = 0\n    for start in range(len(nums)):\n        seen = set([nums[start]])\n        imbalance = 0\n        for end in range(start+1, len(nums)):\n            val = nums[end]\n            if val in seen:\n                ret += imbalance\n                continue\n            if val-1 not in seen and val+1 not in seen:\n                imbalance += 1\n            if val-1 in seen and val+1 in seen:\n                imbalance -= 1\n            ret += imbalance\n            seen.add(val)\n    return ret\n```
['Python3']