Cohomology of the Grothendieck construction