The next states are don 't take  this element and go to (i + 1)th state  else take this element  and go to (i + 2)th state
dp . add ( i , Math . max ( maxSum ( i + 1 , subarr ) , subarr . get ( i ) + maxSum ( i + 2 , subarr ) ) ) ; return dp . get ( i ) ; }