How to solve this Question ? Easy codechef problem

what i understand is the product meaning.
was product of 2 and 4 is 8 .
and thats what i undersand.
i search in google.

Though it is in easy section
But it is not easy problem
It needs dp