(A) Paragraph (2) and subparagraphs (A), (B), (C), and (E) of paragraph (4) shall apply with respect to an individual’s monthly benefits under subsection (b), (c), (d), (e), (f), (g), or (h) only if such individual meets the residency requirements of this paragraph with respect to those benefits.
(B) An individual entitled to benefits under subsection (b), (c), (e), (f), or (g) meets the residency requirements of this paragraph with respect to those benefits only if such individual has resided in the United States, and while so residing bore a spousal relationship to the person on whose wages and self-employment income such entitlement is based, for a total period of not less than 5 years. For purposes of this subparagraph, a period of time for which an individual bears a spousal relationship to another person consists of a period throughout which the individual has been, with respect to such other person, a wife, a husband, a widow, a widower, a divorced wife, a divorced husband, a surviving divorced wife, a surviving divorced husband, a surviving divorced mother, a surviving divorced father, or (as applicable in the course of such period) any two or more of the foregoing.
(C) An individual entitled to benefits under subsection (d) meets the residency requirements of this paragraph with respect to those benefits only if— (i) (I) such individual has resided in the United States (as the child of the person on whose wages and self-employment income such entitlement is based) for a total period of not less than 5 years, or (II) the person on whose wages and self-employment income such entitlement is based, and the individual’s other parent (within the meaning of subsection (h)(3)), if any, have each resided in the United States for a total period of not less than 5 years (or died while residing in the United States), and (ii) in the case of an individual entitled to such benefits as an adopted child, such individual was adopted within the United States by the person on whose wages and self-employment income such entitlement is based, and has lived in the United States with such person and received at least one-half of his or her support from such person for a period (beginning before such individual attained age 18) consisting of— (I) the year immediately before the month in which such person became eligible for old-age insurance benefits or disability insurance benefits or died, whichever occurred first, or (II) if such person had a period of disability which continued until he or she became entitled to old-age insurance benefits or disability insurance benefits or died, the year immediately before the month in which such period of disability began.
(D) An individual entitled to benefits under subsection (h) meets the residency requirements of this paragraph with respect to those benefits only if such individual has resided in the United States, and while so residing was a parent (within the meaning of subsection (h)(3)) of the person on whose wages and self-employment income such entitlement is based, for a total period of not less than 5 years.
(E) This paragraph shall not apply with respect to any individual who is a citizen or resident of a foreign country with which the United States has an agreement in force concluded pursuant to section 433 of this title , except to the extent provided by such agreement.