at the end of each loop (before you display the total, put in :
{assign var="runningtotal" value=+$products[prod_num].total}
Then display $runningtotal
This might do it

haven't tested it though.
For ideas on how this might work look at the bestsellers template.