Well, the formula will depend on the XPath to the fields.
What I usually do when I need to create a condition that is sort of outside the scope of the drop downs in the condition builder is leave the first drop down to whatever it is defaulted to, and the second it's default (usually, the first would be the field you are setting the validation on, and the second is "is equal to"). Then, for the third drop down, select Use a formula.
In the formula editor, you can use the field picker to select your two fields, and put at " + " sign between them.
Then, once you click okay and are back in the conditional formatting, change the first drop down to the "The expression". Now you'll have a larger text area, and it will look something like:
. = my:myFields/my:XPathToOneField + my:myFields/my:XPathToMyOtherField
You can change the "." to 40, and wrap the whole thing in a not:
not(40 = my:myFields/my:XPathToOneField + my:myFields/my:XPathToMyOtherField)
Or, use !=
40 != my:myFields/my:XPathToOneField + my:myFields/my:XPathToMyOtherField
Does that make sense?