If after the sale there remains in the hands of the officer making the sale any surplus money after satisfying the mortgage on the real property sold and after payment of the costs and expenses of the foreclosure and sale, the surplus must be held by such officer for a period of thirty days after the sale unless some person who at the time of the sale had an interest in or lien upon the property sold or some part thereof serves a written notice upon such officer of a claim to the surplus or some part thereof. If no notice of claim is served within the period aforesaid, the officer, upon the expiration of the period and upon demand, shall pay over the surplus to the mortgagor, the mortgagor's legal representatives, or assigns.
N.D.C.C. § 35-22-22