Subject to paragraph (11), paragraph (1) of this subsection shall not apply to any benefit for any month if—
(A) not less than forty of the quarters elapsing before such month are quarters of coverage for the individual on whose wages and self-employment income such benefit is based, or
(B) the individual on whose wages and self-employment income such benefit is based has, before such month, resided in the United States for a period or periods aggregating ten years or more, or
(C) the individual entitled to such benefit is outside the United States while in the active military or naval service of the United States, or
(D) the individual on whose wages and self-employment income such benefit is based died, before such month, either (i) while on active duty or inactive duty training (as those terms are defined in section 410( l ) (2) and (3) of this title) as a member of a uniformed service (as defined in section 410(m) of this title ), or (ii) as the result of a disease or injury which the Secretary of Veterans Affairs determines was incurred or aggravated in line of duty while on active duty (as defined in section 410( l )(2) of this title), or an injury which he determines was incurred or aggravated in line of duty while on inactive duty training (as defined in section 410( l )(3) of this title), as a member of a uniformed service (as defined in section 410(m) of this title ), if the Secretary of Veterans Affairs determines that such individual was discharged or released from the period of such active duty or inactive duty training under conditions other than dishonorable, and if the Secretary of Veterans Affairs certifies to the Commissioner of Social Security his determinations with respect to such individual under this clause, or
(E) the individual on whose employment such benefit is based had been in service covered by the Railroad Retirement Act of 1937 or 1974 [ 45 U.S.C. 228a et seq., 231 et seq.] which was treated as employment covered by this chapter pursuant to the provisions of section 5(k)(1) of the Railroad Retirement Act of 1937 [ 45 U.S.C. 228e(k)(1) ] or section 18(2) of the Railroad Retirement Act of 1974 [ 45 U.S.C. 231q(2) ];
except that subparagraphs (A) and (B) of this paragraph shall not apply in the case of any individual who is a citizen of a foreign country that has in effect a social insurance or pension system which is of general application in such country and which satisfies subparagraph (A) but not subparagraph (B) of paragraph (2), or who is a citizen of a foreign country that has no social insurance or pension system of general application if at any time within five years prior to the month in which the Social Security Amendments of 1967 are enacted (or the first month thereafter for which his benefits are subject to suspension under paragraph (1)) payments to individuals residing in such country were withheld by the Treasury Department under sections 3329(a) and 3330(a) of title 31.