Allocation to income
Any amount to which this subsection applies shall be treated as allocable to income on the contract to the extent that such amount does not exceed the excess (if any) of—
(i)#
the cash value of the contract (determined without regard to any surrender charge) immediately before the amount is received, over
(ii)#
the investment in the contract at such time.