Question

Hello. I have a question, but it is not really about this problem. Generally asking, if you would be grateful to tell me how can I solve this type of dynamic programming problems, could you tell me how can i find the reccurrence easier? Till now I've made backtrackings on small numbers and I tried to search for a reccurrence between the elements, but I find it out pretty hard. Thank you!