First you have to group your report on Quantity.
It gives you one record for each quantity on group level, and
GroupName as numeric value what you will be operating.
After it you have to assign variable and to sumarize it as:
whileprintingrecords;
global nubervar nQty := nQty + GroupName;
this formula will be in your new Group header or footer.
And you can suppress it
Now you have to display your calculations at the end of the report,
in the report footer:
whileprintingrecords;
global nubervar nQty;
Because it's global, you probably would be able to display it in the
report header.
If it wouldn't work, well, you will have to build subreport, same
what your main report, put it in main report header and display
summary result what you receive in subreport with same technic
what I described earlier.
Only in this case you don't need to declare "global".
Just variable nubervar nQty