Question

I am having a hard time figuring out the mechanism for this reaction. I completely get why it goes to that carbon, just not the middle part.

enter image description here