Courthouse to be demolished for affordable housing