Added the sum algorithm