Multiscale KAM theorem for Hamiltonian systems