How is "cumulative PoW" calculated to decide between competing chains?

Chain 1 has blocks with targets diff1, diff2, diff3, diff4

Chain 2 has blocks with targets DIFF1 DIFF2 DIFF3

What’s the formula to derive the (relative) cumulative proof of works from these chains to find out which one is stronger?