Multi-instantons, three-dimensional gauge theory, and the Gauss-Bonnet-Chern theorem