Algorithm sum