implementation of segment tree - range update and range queries.
corrected the logic a little.
the sum should also be updated while pushing the pending changes.