Role of surface integrals in the Hamiltonian formulation of general relativity