Suppose there are two objects $A$ & $B$ of same mass; the former has specific heat capacity $C_A$ and the later has $C_B$ such that $C_A\gt C_B.$ Let $A$ be at temperature $T$ while $B$ be at $T+\Delta T.$ So, in order to attain thermal equilibrium, they have to attain the same temperature $T+ \frac{\Delta T}{2}.$ That means there would be a change of $\frac{\Delta T}{2}$ in both bodies. For that, $A$ must gain heat energy $Q_A= m\;C_A\cdot \frac{\Delta T}{2}$ while $B$ has to loss heat energy $Q_B=m\;C_B\cdot \frac{\Delta T}{2}.$ Now, $Q_A-Q_B\gt 0$ since $C_A\gt C_B.$
Then in order to attain the equilibrium temperature, $A$ has to get $Q_A$ energy which it receives partly from $B$ viz. $Q_B$ but where does the additional heat energy $Q_A-Q_B$ come from? It can't come from $B$ as that would deviate it from achieving the thermal temperature; $B$ can lose only $Q_B$ in order to attain $T+\frac{\Delta T}{2}.$ But where does $A$ get the extra energy $Q_A- Q_B$ from?
I'm confused as I thought so-far that when two bodies achieve thermal equilibrium, they do it by exchanging heat energy between themselves - the cooler body receives heat energy fro the hotter body till the equilibrium is reached.
But here, it seems that $A$ in order to achieve thermal equilibrium, needs energy $Q_A$ which cannot be provided by $B$ since the energy $Q_B$ it releases is less than $Q_A.$ Where would then the extra energy $Q_A-Q_B$ come from?
Let's say, somehow $A$ gained that energy from the surroundings; however what would happen if they were isolated from the surroundings?
I don't know where I'm mistaking. Is it true that the hotter body itself provide the required energy to the cooler body to attain thermal equilibrium?
Please help.