Magnetic relaxation of type-II superconductors in a mixed state of entrapped and shielded flux