Nifty closes flat at 24,326.65 as midcaps lead gains amid mixed cues