Adsorption energies of H and H2: a quantum-chemical study