  Strong solar flares occur in $\delta $-spots characterized by the
opposite-polarity magnetic fluxes in a single penumbra. Sunspot formation via
flux emergence from the convection zone to the photosphere can be strongly
affected by convective turbulent flows. It has not yet been shown how crucial
convective flows are for the formation of $\delta$-spots. The aim of this study
is to reveal the impact of convective flows in the convection zone on the
formation and evolution of sunspot magnetic fields. We simulated the emergence
and transport of magnetic flux tubes in the convection zone using radiative
magnetohydrodynamics code R2D2. We carried out 93 simulations by allocating the
twisted flux tubes to different positions in the convection zone. As a result,
both $\delta$-type and $\beta$-type magnetic distributions were reproduced only
by the differences in the convective flows surrounding the flux tubes. The
$\delta $-spots were formed by the collision of positive and negative magnetic
fluxes on the photosphere. The unipolar and bipolar rotations of the
$\delta$-spots were driven by magnetic twist and writhe, transporting magnetic
helicity from the convection zone to the corona. We detected a strong
correlation between the distribution of the nonpotential magnetic field in the
photosphere and the position of the downflow plume in the convection zone. The
correlation could be detected $20$-$30$ h before the flux emergence. The
results suggest that high free energy regions in the photosphere can be
predicted even before the magnetic flux appears in the photosphere by detecting
the downflow profile in the convection zone.

Solar and Stellar Astrophysics