4 、Divide the set $\{1,2, \cdots, n\}$ into two subsets arbitrarily, and there must be one subset that contains 2017 positive integers (not necessarily distinct) $x_{1}, x_{2}, \cdots, x_{2017}$ such that $x_{1}+x_{2}+\cdots+x_{2016}=x_{2017}$. The smallest positive integer $n$ that satisfies this condition is $\qquad$
4. 4066271

Analysis: On one hand, take $A=\{1,2, \ldots, 2015\} \cup\left\{2016^{2}, 2016^{2}+1, \ldots, 2016^{2}+2014\right\}$, $B=\left\{2016,2017, \ldots, 2016^{2}-1\right\}$. Clearly, at this point, there do not exist 2017 elements in $A$ and $B$ such that $x_{1}+x_{2}+\cdots+x_{2016}=x_{2017}$. Therefore, $n>2016^{2}+2014=4066270$.

On the other hand, when $n=4066271$, assume there is no partition that satisfies the condition. Then, when $1 \in A$, $2016 \in B$, at this time $2016^{2} \in A$. Since $4066271=2016^{2}+2015 \times 1$, it follows that $4066271 \in B$. Also, $2016^{2} \in A$, and $2016^{2}=2017 \times 2015+1 \times 1$, so $2017 \in B$. But $4066271=2017 \times 2015+2016$, which is a contradiction. Therefore, the minimum value of $n$ is 4066271.