partial sum implemented