sum values in a smarter order