Function for computing penalty written.