The superconducting transition temperature (TC) in a FeSe monolayer on SrTiO3 is enhanced up to 100 K (refs ,,,). High TC is also found in bulk iron chalcogenides with similar electronic structure to that of monolayer FeSe, which suggests that higher TC may be achieved through electron doping, pushing the Fermi surface (FS) topology towards leaving only electron pockets. Such an observation, however, has been limited to chalcogenides, and is in contrast to the iron pnictides, for which the maximum TC is achieved with both hole and electron pockets forming considerable FS nesting instability. Here, we report angle-resolved photoemission characterization revealing a monotonic increase of TC from 24 to 41.5 K upon surface doping on optimally doped Ba(Fe1-xCox)2As2. The doping changes the overall FS topology towards that of chalcogenides through a rigid downward band shift. Our findings suggest that higher electron doping and concomitant changes in FS topology are favourable conditions for the superconductivity, not only for iron chalcogenides, but also for iron pnictides.