Sec. 8-2g. Special exemption from density limits for construction of affordable housing. (a) Notwithstanding the provisions of any special act, any zoning commission existing pursuant to this chapter and any municipal agency exercising the powers of a zoning commission pursuant to any special act may provide by regulation for a special exemption from density limits established for any zoning district, or special exception use, in which multifamily dwellings are permitted, in accordance with the requirements contained in subsection (b) of this section. Such special exemption shall allow the construction of a designated number of such permitted multifamily dwelling units in excess of applicable density limits, in accordance with a contract entered into between a developer applying for the special exemption and the municipality. Any such contract shall provide: (1) For each dwelling unit constructed by the developer in excess of the number of such units permitted by applicable density limits, the developer shall construct in the municipality a unit of affordable housing, as defined in section 8-39a, which is of comparable size and workmanship; (2) for a period which shall not be less than thirty years from the date of completion of any units of affordable housing constructed pursuant to subdivision (1) of this subsection, such units of affordable housing shall be offered for sale or rent only to persons and families having such income as the agency created or designated under subsection (b) of this section may establish but which shall not exceed the area median income of the municipality as determined by the United States Department of Housing and Urban Development; (3) the sale price or rent for any such unit of affordable housing shall not exceed an amount which shall