Handle sum expression more efficiently.