The initial-equilibrium relation was used in the last step. The first term is the incremental electrical cost and the second is the change in chemical cost from their initial balanced values.
If the intended initial reference is uncharged with Vm0=0 and ci0=co, then n0=coV and the requested form in the listed variables is