The following may be helpful to those struggling with the logic of the formula Total=P+H+W -{Sum of Exactly 2 groups members}-2*PnHnW + Neither .
First, forget this formula for a moment and rather recall the first "easier" formula: Total = A + B + C - (all cases of 2 group overlap, which equals AnB + AnC + BnC) + (the single 3 group overlap, which is AnBnC, or g) + (neither)
Recall that when we subtract all cases of group overlap, AnB + AnC + BnC, then we also subtract the 3 group overlap, g, 3 times. Since we add g 3 times when we add A +B + C, we are back at 0 regarding g, hence why we add it back following this subtraction, as you can see up there in the first formula.
In the gmat question we have above, the "simpler" first formula rendition would therefore go: 59 = 22 + 27 + 28 - (AnB + AnC + BnC) + g + 0
We know that the total number of members in exactly two groups (so NOT the ones in all three) is 6.
Now, can we make AnB + AnC + BnC just equal 6? No, since AnB, and the rest of them, also include those members of all three groups, and thus may be larger than 6. The work around is that we simply need to account for g in each case, by including it explicitly in the formula and then set the part that is NOT g equal to 6.
Hence, AnB = (some part of the total 6) + g, and the same for the others. Just to give 'the part of the total 6' on A and B's side a name, let's substitute 'anb'. Don't get confused here: anb is just AnB with g subtracted.
Hence AnB + AnC + BnC = (anb + g) + (anc + g) + (bnc + g)
But what does anb equal? We don't know, but what we DO know that anb + anc + bnc, all the sets that have ONLY members of two and no more or less, is equal to 6.
Hence anb + anc + bnc = 6
With this understood we just replace anb, anc, and bnc with 6.
Hence, (AnB + AnC + BnC) = (6 + g + g + g)
Back to the first formula rendition, we now have 59 = 22 + 27 + 28 - (6 + g + g +g) + g + 0
Simplified (a little): 59 = 22 + 27 + 28 - 6 - g - g - g + g + 0
Simplified (a little more): 59 = 22 + 27 + 28 - 6 - 2g + 0
But wait, this just is the second formula!
Second formula: Total = P+H+W -{Sum of Exactly 2 groups members}-2*PnHnW + Neither
Where we left off: 59 = 22 + 27 + 28 - 6 - 2g + 0
You can now hopefully see WHY 6, the sum of those in exactly 2 groups, is subtracted, as well as WHY 2g is subtracted.