(using a bit more general notation)
For $Y$ is $n\times 1$ and $X$ is $n \times p$ we have the centering matrix $C_n = I_n - \tfrac{1}{n}J_n$ where $I_n$ is the $n\times n$ identity matrix and $J_n$ is the $n \times n$ matrix of ones. Your centered matrices can then be computed as $\tilde{Y}=C_nY$ and $\tilde{X}=C_nX$. The least squares solution of regressing $X$ on $Y$ is
$$
\hat{\beta} = (X^\intercal X)^{-1}X^\intercal Y
$$
while the least squares solution of regressing $\tilde{X}$ on $\tilde{Y}$ is
$$
\begin{align*}
\hat{\tilde{\beta}} &= (\tilde{X}^\intercal \tilde{X})^{-1}\tilde{X}^\intercal \tilde{Y}\\
&=((C_nX)^\intercal C_nX)^{-1}(C_nX)^\intercal (C_nY)\\
&=(X^\intercal C_n^\intercal C_n X)^{-1}X^\intercal C_n^\intercal C_nY\\
&= (X^\intercal X)^{-1}X^\intercal Y\\
&= \hat{\beta}
\end{align*}
$$
where $C_n^\intercal = C_n$ and $C_nC_n = I_n$, i.e. $C_n$ is idempotent (you should be able to show this).
QED as they say.