If, at the time of the crime, the capacity of the perpetrator to understand the wrongfulness of his conduct or of acting in accordance with this understanding is substantially diminished due to the existence of grounds set forth in § 20, his punishment shall be reduced in accordance with the provisions of § 49(l).