Somehow I just brute forced the calculation and managed to get it.
I cancelled the A pretty early but the struggle was simplifying the derivative of E with respect to r (and also forgetting the odd minus signs here and there) but the answer was relieving.
Thank you!