by foreclosure (or instrument in lieu of foreclosure) unless the Secretary determines that such acquisition is part of an arrangement with the taxpayer a purpose of which is to terminate such period, or (II) on the last day of the period specified in subparagraph (I) if the housing credit agency is unable to present during such period a qualified contract for the acquisition of the middle-income portion of the building by any person who will continue to operate such portion as a qualified middle-income building. Subclause (II) shall not apply to the extent more stringent requirements are provided in the agreement or in State law. (ii) Eviction, etc. of existing middle-income tenants not permitted The termination of an extended use period under clause (i) shall not be construed to permit before the close of the 3-year period following such termination— (I) the eviction or the termination of tenancy (other than for good cause) of an existing tenant of any middle-income unit, or (II) any increase in the gross rent with respect to such unit not otherwise permitted under this section. (F) Qualified contract For purposes of subparagraph (E), the term qualified contract means a bona fide contract to acquire (within a reasonable period after the contract is entered into) the nonmiddle-income portion of the building for fair market value and the middle-income portion of the building for an amount not less than the applicable fraction (specified in the extended middle-income housing commitment) of— (i) the sum of— (I) the outstanding indebtedness secured by, or with respect to, the building, (II) the adjusted investor equity in the building, plus (III) other capital contributions not reflected in the amounts described in subclause (I) or (II), reduced by (ii) cash distributions from (or available for distribution from) the project. The Secretary shall prescribe such regulations as may be necessary or appropriate to carry out this paragraph, including regulations to prevent the manipulation of the amount determined under