Help with a crankshaft position sensor

I’ve recently completed a head gasket repair on my '98 Contour. I have not been able to get it to start (no spark), and…at the end of a lenghty troubleshooting process…determined the problem to be a crankshaft position sensor that was damaged somehow in the repair process.

Since it’s the end plugged into the block (the “male” part) that’s destroyed, I need to remove the old one and install a new one.

Can anyone tell me how that’s done? It’s hiding behind the manifold, so it’s hard to see exactly how to remove it.