9. Let $A=\{1,2,3, \cdots, 2 n, 2 n+1\}, B \subseteq A$, and for any three distinct elements $x, y, z$ in $B$, we have $x+y \neq z$. Find the maximum value of $|B|$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
9. Let $D=\{1,3,5, \cdots, 2 n+1\}, E=\{2,4,6, \cdots, 2 n\}$, then $A=D \cup E$. Let $B=\left\{x_{1}\right.$, $\left.x_{2}, \cdots, x_{m}, y_{1}, y_{2}, \cdots, y_{k}\right\}$, where $x_{1}, x_{2}, \cdots, x_{m} \in D, y_{1}, y_{2}, \cdots, y_{k} \in E$, and $x_{1}<x_{2}<\cdots<x_{m}$. By the problem, $x_{m}-x_{i} \neq y_{j}$, where $i=1,2, \cdots, m-1, j=1,2, \cdots, k$, and $2 \leqslant x_{m}-x_{i} \leqslant 2 n$, i.e., $x_{m}-x_{i} \in E, i=1,2, \cdots, m-1$, so $x_{m}-x_{1}, x_{m}-x_{2}, \cdots, x_{m}-x_{m-1}, y_{1}$, $y_{2}, \cdots, y_{k}$ are distinct elements in $E$. Thus $(m-1)+k \leqslant|E|=n,|B| \leqslant m+k \leqslant n+1$. If $B=\{n+1, n+2, n+3, \cdots, 2 n, 2 n+1\}$, for any two different elements $x, y$ in $B$, we have $x+y \geqslant 2 n+3$, i.e., $B$ meets the condition, thus the maximum value of $|B|$ is $n+1$.