sum and product applied with function