for the taxable year to any applicable retirement plan to the extent such applicable annual additions exceed the excess (if any) of— (1) the applicable dollar amount for the taxable year, over (2) the aggregate balances to the credit of the individual (whether as a participant, owner, or beneficiary) in all applicable retirement plans (determined as of the close of the calendar year preceding the calendar year in which the taxable year begins). (b) Rules relating to contribution limitations (1) Plans other than certain IRAs (A) In general Except as provided in paragraph (2), applicable annual additions in excess of the limitation under subsection (a) shall be treated for purposes of this title in the same manner as excess deferrals are treated under section 402(g). (B) Special rule for after tax contributions If, without regard to this paragraph, any portion of an applicable annual addition to which subparagraph (A) applies with respect to an individual is not excludable from gross income of the individual (or no deduction is allowable to the individual with respect to such portion), such portion shall not be— (i) includible in gross income by reason of the application of subparagraph (A), or (ii) taken into account in computing the investment in the contract for purposes of section 72. (2) Special rule for IRAs (A) In general In the case of an applicable retirement plan which is an individual retirement plan (other than a simplified employee pension under section 408(k) or a simple retirement account under section 408(p)), any applicable annual addition to such plan in excess of the limitation under subsection (a) shall be treated for purposes of sections 408 and 408A as a contribution for the taxable year in excess of the maximum amount allowable as a deduction under section 219 for the taxable year. (B) After tax contributions In the case of applicable annual additions in excess of the limitation under subsection (a)— (i) which are treated as designated nondeductible contributions under section 408(o), rules