modify sum function(parameter as arraylist) to demo code