6. In a regular $(n+2)$-gon, two vertices are randomly selected, and a line passing through them is drawn. Let $p_{n}$ denote the probability that the difference in the number of vertices on either side of this line does not exceed 1. Then the value of $\sum_{i=1}^{2018} p_{i} p_{i+1}$ is $\qquad$.
6. $\frac{1009}{1010}$.
By symmetry, without loss of generality, consider a fixed vertex $A$.
When $n=2 k$, among the remaining $2 k+1$ vertices, only the vertex symmetric to $A$ about the center can be chosen, so $p_{2 k}=\frac{1}{2 k+1}$.

When $n=2 k-1$, among the remaining $2 k$ vertices, one of the two farthest points from $A$ can be chosen, so
$$
\begin{array}{l}
p_{2 k-1}=\frac{2}{2 k}=\frac{1}{k} . \\
\text { Hence } \sum_{i=1}^{2018} p_{i} p_{i+1}=\sum_{k=1}^{1009} p_{2 k}\left(p_{2 k-1}+p_{2 k+1}\right) \\
=\sum_{k=0}^{1000} \frac{1}{2 k+1}\left(\frac{1}{k}+\frac{1}{k+1}\right) \\
=\sum_{k=1}^{1009}\left(\frac{1}{k}-\frac{1}{k+1}\right)=\frac{1009}{1010} .
\end{array}
$$