Any amount deducted by the state or by any public department or official thereof, pursuant to the terms of the contract, from the retained payments due the contractor shall be deducted first from that portion of the retained payments for which no security has been substituted and then from the proceeds of any deposited security. In the latter case, the contractor shall be entitled to receive interest, coupons, or income only from those securities which remain after the amount has been deducted.