Simple algorithms on an array - compute sum and min