There's nothing particularly OCaml-like in this problem. Most likely your main task is to learn to solve problems recursively.
The way to solve a problem recursively is to break it into two cases:
a. The input is so small the answer is ridiculously obvious.
b. The answer isn't so small, but you already have a function that works for (strictly) smaller inputs.
To solve the problem, you need to decide how to determine whether the input size is ridiculously small (a very short list), and how to use another function that works for smaller lists to solve your problem with a larger list. Then your own function is that other function (when called recursively).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…