In this formula
=SUM(2524+E5-D5)
the SUM function is redundant
this will give the same value
=2524+E5-D5
If this gives you an error then either E5 or D5 is probably text. If they are supposed to be empty then ensure they are and don't contain any spaces or other characters.
If E5 and/or D5 might contain text or numbers and you want to use the numbers when present but ignore text then try
=SUM(2524,E5)-SUM(D5)
or
=2524+N(E5)-N(D5)