Stability of molecules by resonance
In chemical resonance, the same principle holds as in electrostatics:

"In general, the boundary structures of a conjugated system with the lowest energy are those
...
- in which the distance between charges of opposite sign is as small as possible and the distance between charges of the same sign is as large as possible
... ."

Wikipedia: Resonance (chemistry) - Major and minor contributors:
"Energetically unfavourable and therefore less favorable structures are minor contributors. With rules listed in rough order of diminishing importance, major contributors are generally structures that
...
3. carry a minimum of formally charged atoms, with the separation for unlike and like charges minimized and maximized, respectively
... ."