  We characterize the smallest codimension components of the Hodge locus of
smooth degree $d$ hypersurfaces of the projective space $\mathbb{P}^{n+1}$ of
even dimension $n$, passing through the Fermat variety (with $d\neq 3,4,6$).
They correspond to the locus of hypersurfaces containing a linear algebraic
cycle of dimension $\frac{n}{2}$. Furthermore, we prove that among all the
local Hodge loci associated to a non-linear cycle passing through Fermat, the
ones associated to a complete intersection cycle of type $(1,1,\ldots,1,2)$
attain the minimal possible codimension of their Zariski tangent spaces. This
answers a conjecture of Movasati, and generalizes a result of Voisin about the
first gap between the codimension of the components of the Noether-Lefschetz
locus to arbitrary dimension, provided that they contain the Fermat variety.
