Boredom
MediumRating 1500Codeforces1-D Dynamic Programming
Approach hintTry it first, then revealHide
Choosing value v forbids v - 1 and v + 1. Weigh each value as v * cnt[v] and run a House Robber style DP over values in increasing order, using 64-bit sums.