Sponsored
Use these hints if you're stuck. Try solving on your own first.
Partition the array by common integers, and choose the path with larger sum with a DP technique.
Solve with full IDE support and test cases