class Solution:
    def deleteAndEarn(self, n: List[int]) -> int:
    	if not n: return 0
    	a, b, C = 0, n.count(1), collections.Counter(n)
    	for i in range(2,max(n)+1): b, a = max(C[i]*i + a, b), b
    	return b