Let $X$ be a quasiprojective scheme over a field $k$. We define that a $0$-dimensional subscheme $Z$ is of length $n$ if:
$\operatorname{dim}_k \operatorname{H}^0(Z,\mathcal{O}_Z)=\sum_{p\in Supp(Z)}\operatorname{dim}_k(\mathcal{O}_{Z,p})=n$
I don’t understand how can we get the first equality? I know there is an isomorphism between sections $\Gamma(Z,\mathcal{O}_Z)$ and $\operatorname{H}^0$, but I can’t go further. Hope someone could help. Thanks!