§ 40-d. Penalty for violation. Any person who shall violate any of the provisions of the foregoing section, or subdivision three of section 240.30 or section 240.31 of the penal law, or who shall aid or incite the violation of any of said provisions shall for each and every violation thereof be liable to a penalty of not less than one hundred dollars nor more than five hundred dollars, to be recovered by the person aggrieved thereby in any court of competent jurisdiction in the county in which the defendant shall reside. In addition, any person who shall violate any of the provisions of the foregoing section shall be deemed guilty of a class A misdemeanor. At or before the commencement of any action under this section, notice thereof shall be served upon the attorney general.