  In this paper it is shown that if $\mu$ is a finite Radon measure in $\mathbb
R^d$ which is $n$-rectifiable and $1\leq p\leq 2$, then $$\int_0^\infty
\beta_{\mu,p}^n(x,r)^2\,\frac{dr}r<\infty \quad {for $\mu$-a.e. $x\in\mathbb
R^d$,}$$ where $$\beta_{\mu,p}^n(x,r) = \inf_L (\frac1{r^n} \int_{\bar B(x,r)}
(\frac{\mathrm dist(y,L)}{r})^p\,d\mu(y))^{1/p},$$ with the infimum taken over
all the $n$-planes $L\subset \mathbb R^d$. The $\beta_{\mu,p}^n$ coefficients
are the same as the ones considered by David and Semmes in the setting of the
so called uniform $n$-rectifiability. An analogous necessary condition for
$n$-rectifiability in terms of other coefficients involving some variant of the
Wasserstein distance $W_1$ is also proved.
