A loss sustained by a bank in excess of its undivided profits and any capital contingency reserves shall be charged to its surplus account or, with the approval of the department, carried as negative undivided profits. The bank's undivided profits and surplus account shall thereafter be reimbursed from earnings, and no dividends may be declared or paid by the bank until any negative undivided profits are eliminated and the surplus account is restored to at least the amount from which the surplus was originally reduced.