Given an ensemble of electric charges, a displacement of these charges without external intervention corresponds to work done at the expense of the electrostatic energy of the system. There is a force acting on each charge due to the electric field due to all other charges. Let charge $q_{s}$ be at $\mathbf{x}_{s}$ and let $\delta \mathbf{x} _{s}$ be the displacement of this charge. The work done is $$ d W=\sum_{s} \mathbf{F}_{s} \cdot \delta \mathbf{x}_{s} $$ Let $\phi\left(\mathbf{x}_{s}\right)$ be the potential at $\mathbf{x}_{s}$ due to all the charges except $q_{s}$ : $$ \phi\left(\mathbf{x}_{s}\right)=\sum_{t \neq s} \frac{q_{t}}{\left|\mathbf{x}-\mathbf{x}_ {t}\right|} $$ Then $$ \mathbf{F}_{s} \cdot \delta \mathbf{x}_{s}=\delta \mathbf{x}_{s} \cdot q_{s} \mathbf{E}\left(\mathbf {x}_{s}\right)=-\delta \mathbf{x}_{s} \cdot \nabla_{s} \sum_{t \neq s} \frac{q_{t} q_{s}} {\left|\mathbf{x}_{s}-\mathbf{x}_{t}\right|} $$