write min heap