In the notes that I'm working through it says the following: "Let $X_1,...,X_n$ be a random sample from $N(\mu,\sigma)$
$$\sum^{n}_{i=1}\Bigg[\frac{(X_i-\mu)}{\sigma}\Bigg]^2$$ has a $\chi^2$ distribution with $n$ degrees of freedom.
Now if we modify this by replacing $\mu$ with $\overline{X}$ the distribution changes and we obtain: $$\sum^{n}_{i=1}\Bigg[\frac{(X_i-\overline{X})}{\sigma}\Bigg]^2$$ has a $\chi^2$ distribution with $n-1$ degrees of freedom."
My question is: why does the number of degrees of freedom change?
My understanding of what a degree of freedom is that the number of degrees of freedom is the number of values in the final calculation of a statistic that are free to vary. So surely as there are $n$ $X_i$ even when we introduce $\overline{X}$ the number of values that are free to change in the calculation of the statistic is still the same??