Energy-optimized GTO basis sets for LCAO calculations. A gradient approach