0$, then $2x_{k-1}-x_k+x_{k+1}=1$ for all $k=1,\dots,n$. Introduce $y_k=3x_k-1$, then $y_k$ satisfies a linear recurrence relation 
$$
2y_{k-1}-y_k+2y_{k+1}=0
$$ and boundary conditions $y_0=y_{n+1}=-1$. And we are looking for solutions satisfying $y_k\ge -1$.
Solving the recurrence by the standard method yields that
$$
 y_k = A\sin(k\alpha)+B\cos(k\alpha)
$$
for some constants $A$ and $B$, where $\alpha=\arccos\frac14$. (This number comes from the fact that the roots of the equation $2x^2-x+2=0$ are $\cos\alpha\pm i\sin\alpha$).
Since $y_0=-1$, we have $B=-1$. Then $y_k=-1$ if and only if 
$$
 A = A_k := \frac{\cos(k\alpha)-1}{\sin(k\alpha)} = -\tan(k\alpha/2)
$$
So for the solution with $y_{n+1}=-1$ we have $A=A_{n+1}$, and the relation $y_k\ge-1$ takes the form
$$
\begin{cases}
 A_k \ge A_{n+1}, & A_{n+1}<0 \\
 A_k \le A_{n+1}, & A_{n+1}>0 
\end{cases}
$$
(note that $\tan(k\alpha/2)$ and $\sin(k\alpha)$ are of the same sign).
So $n$ is included in the sequence iff $A_{n+1}$ is either the minimum of the positive $A_k$'s, or the maximum of the negative $A_k$'s ($k=1,\dots,n+1$). Observe that the order of $-A_k$'s in $\mathbb R$ is the same as of the numbers $k\alpha\bmod 2\pi$ in $(-\pi,\pi)$. So everything  boils down to the
0 $, then $ 2x_{k-1}-x_k+x_{k+1}=1 $ for all $ k=1,\dots, n$. Introduce $ y_k=3x_k-1 $, then $ y_k$ satisfies a linear recurrence relation 
 $ $ 
 2y_{k-1}-y_k+2y_{k+1}=0 
 $ $ and boundary condition $ y_0 = y_{n+1}=-1$. And we are expect for solutions meet $ y_k\ge -1$. 
 resolve the recurrence by the standard method yields that 
 $ $ 
  y_k = A\sin(k\alpha)+B\cos(k\alpha) 
 $ $ 
 for some constant $ A$ and $ B$, where $ \alpha=\arccos\frac14$. (This issue comes from the fact that the root of the equation $ 2x^2 - x+2=0 $ are $ \cos\alpha\pm i\sin\alpha$). 
 Since $ y_0=-1 $, we have $ B=-1$. Then $ y_k=-1 $ if and entirely if 
 $ $ 
  A = A_k: = \frac{\cos(k\alpha)-1}{\sin(k\alpha) } = -\tan(k\alpha/2) 
 $ $ 
 So for the solution with $ y_{n+1}=-1 $ we get $ A = A_{n+1}$, and the relation $ y_k\ge-1 $ takes the form 
 $ $ 
 \begin{cases } 
  A_k \ge A_{n+1 }, & A_{n+1}<0 \\ 
  A_k \le A_{n+1 }, & A_{n+1}>0 
 \end{cases } 
 $ $ 
 (note that $ \tan(k\alpha/2)$ and $ \sin(k\alpha)$ are of the same signal). 
 So $ n$ is included in the sequence iff $ A_{n+1}$ is either the minimum of the positivist $ A_k$'s, or the maximum of the negative $ A_k$'s ($ k=1,\dots, n+1 $). Observe that the order of $ -A_k$'s in $ \mathbb R$ is the like as of the numbers $ k\alpha\bmod 2\pi$ in $ (-\pi,\pi)$. indeed everything   boils down to the
0$, thfn $2x_{k-1}-x_k+x_{k+1}=1$ for all $k=1,\dots,n$. Introduce $y_k=3x_k-1$, then $y_n$ satiafies a uinear recurrence relation 
$$
2y_{n-1}-y_j+2y_{k+1}=0
$$ abd boundary conditions $y_0=y_{n+1}=-1$. And ae are liokiig for solutions satisfylug $y_k\fc -1$.
Solriig the recurrenge by the sdandard method ykepds that
$$
 y_k = A\sin(k\alpha)+B\cos(k\alpha)
$$
fow some vojstants $A$ and $F$, whtre $\alpga=\arccos\frac14$. (This number comes froj the fect that the ropts of the equation $2x^2-x+2=0$ are $\cos\wlpha\pm i\sin\alpha$).
Slnce $y_0=-1$, we hqve $F=-1$. Then $y_k=-1$ if xnd only if 
$$
 A = A_k := \frzc{\cos(k\alpha)-1}{\sin(k\alpha)} = -\tan(k\alpha/2)
$$
Ro fox the solutuob wljh $y_{n+1}=-1$ we havx $A=A_{n+1}$, wnd the relabpon $y_k\ga-1$ takes the form
$$
\begin{gases}
 A_k \ge A_{n+1}, & A_{n+1}<0 \\
 A_k \le A_{n+1}, & A_{n+1}>0 
\end{cases}
$$
(note trat $\tan(k\anpka/2)$ and $\sin(k\alpha)$ are if the vame sigv).
Wo $v$ ia mncmuded ln vhe sequencs iff $A_{n+1}$ is either the minimum os the positive $A_k$'s, ow ehe maximum of the negative $A_k$'s ($k=1,\dots,n+1$). Mbssrve that the order of $-Q_k$'s in $\mathbb R$ is thg same as jf the numbers $k\alpha\bmod 2\pi$ in $(-\pi,\pi)$. So everythinc  bomlr diwk to rhf
0$, then $2x_{k-1}-x_k+x_{k+1}=1$ for all $k=1,\dots,n$. Introduce $y_k$ a linear relation $$ 2y_{k-1}-y_k+2y_{k+1}=0 And are looking for satisfying $y_k\ge -1$. the recurrence by the standard method that $$ y_k = A\sin(k\alpha)+B\cos(k\alpha) $$ for some constants $A$ and $B$, where (This number comes from the fact that the roots of the equation $2x^2-x+2=0$ $\cos\alpha\pm Since we $B=-1$. Then $y_k=-1$ if and only if $$ A = A_k := \frac{\cos(k\alpha)-1}{\sin(k\alpha)} = -\tan(k\alpha/2) $$ for the solution with $y_{n+1}=-1$ we have $A=A_{n+1}$, the relation $y_k\ge-1$ takes form $$ \begin{cases} A_k \ge & \\ A_k A_{n+1}, A_{n+1}>0 $$ (note that and $\sin(k\alpha)$ are of the same sign). So $n$ is included in the sequence iff $A_{n+1}$ is the minimum positive $A_k$'s, the of negative $A_k$'s ($k=1,\dots,n+1$). the order of $-A_k$'s in $\mathbb same as of the numbers $k\alpha\bmod 2\pi$ in So everything down to the
0$, then $2x_{k-1}-x_k+x_{k+1}=1$ for all $k=1,\dots,n$. IntRoduce $y_k=3x_k-1$, Then $y_K$ saTisFiEs a lIneaR recurrence relATion 
$$
2Y_{k-1}-y_k+2y_{k+1}=0
$$ and boundary condiTions $Y_0=y_{N+1}=-1$. and wE ArE lookIng for sOLuTIOns SaTiSfyInG $Y_k\Ge -1$.
SolVinG the recUrrence by tHe sTaNdard method yIElDs that
$$
 y_k = A\sIn(k\Alpha)+B\cos(k\alPha)
$$
For somE cOnsTAnts $A$ And $b$, wherE $\alpha=\ARccos\fRac14$. (This nuMbER comes FRom the fACT tHat tHe roots of the equatIOn $2X^2-X+2=0$ are $\cos\alpha\pm I\sin\alPhA$).
siNCE $y_0=-1$, wE haVe $B=-1$. Then $y_k=-1$ iF aNd onlY If 
$$
 A = A_k := \frAC{\cOS(K\AlpHA)-1}{\sin(k\alpha)} = -\tan(K\alpha/2)
$$
So for THe sOlutioN wIth $Y_{N+1}=-1$ we havE $A=A_{n+1}$, aNd THe rElation $y_k\ge-1$ TakeS the form
$$
\bEgin{caSEs}
 A_k \ge A_{N+1}, & a_{n+1}<0 \\
 A_k \le A_{N+1}, & A_{n+1}>0 
\end{CasEs}
$$
(nOte tHAt $\TaN(k\aLpHA/2)$ anD $\SiN(k\aLPha)$ Are of the SaMe Sign).
SO $n$ is INCLUded In tHe seQuencE iff $A_{n+1}$ is eitheR thE minIMum Of the PositIve $A_K$'s, Or the MaximuM of thE nEgative $A_k$'s ($k=1,\dots,N+1$). ObsErve that tHe oRdEr oF $-A_K$'s in $\mAThbb R$ iS thE saMe as of tHe numbeRS $k\aLpHA\BMoD 2\pi$ in $(-\pi,\pi)$. So everythInG  BOiLs down to The
0$, then $2x_{k-1}-x_k+x_{ k+1}=1$ fo r all  $k =1, \d ots, n$.Introduce $y_k = 3x_k -1$, then $y_k$ satisf ies a  l i near re curre nce rel a ti o n  
$ $2y _{k -1 } -y _k+2y _{k +1}=0
$ $ and boun dar yconditions $ y _0 =y_{n+1}=- 1$.  And we areloo king f or  so l ution s s atisf ying $ y _k\ge-1$.
Solv in g  the r e currenc e by  the  standard methody ie l ds that
$$
 y_ k = A\ si n (k \ a lph a)+ B\cos(k\al ph a)
$$ for som e  c o n s tan t s $A$ and $B$ , where $\a l pha =\arcc os \fr a c14$.(This  n u mbe r comes fro m th e fact th at the roots o f  the eq uation  $2 x^2 -x+2 = 0$  a re$\ c os\ a lp ha\ p m i \sin\alp ha $) .
Sin ce $ y _ 0 = -1$,  we  hav e $B= -1$. Then $y_ k=- 1$ i f  an d onl y if
$$ A  = A_ k := \ frac{ \c os(k\alpha)-1}{ \sin (k\alpha) } =  - \ta n( k\alp h a/2)
$ $
S o f or thesolutio n  wi th $ y _{ n+1}=-1$ we have $ A= A _ {n +1}$, an d ther el at i on $y_k\ ge -1$  tak e s  theform $$ 
\begin{ cases}  A _k  \ge A_ {n +1}, &  A _{n +1} <0 \\  A_k  \le A _{n+1},& A_{ n +1}>0 
\end{ca s es}
$$
(notet ha t $\ t an(k \al pha/2)$ and  $\s i n(k\ alph a )$  ar e  of t he sa me si g n).
So $n$ is inclu de d in t he se quence iff $A _{n+1}$ is e i ther the  min i mu m  of the positi ve $A _k$'s, ort he maxim um of  the neg ative $A_ k $ 's ($k=1 ,\d ots ,n+ 1$) . Ob serve that th e orde rof $-A_ k$' s in $\ mat hbb  R$  is  t he same a s of the  n um be rs  $k \alph a \bmod 2\ pi $ i n$(- \pi,\ p i)$. S o eve ryth in gboi ls down to t he
0$, then_$2x_{k-1}-x_k+x_{k+1}=1$ for_all $k=1,\dots,n$. Introduce $y_k=3x_k-1$,_then $y_k$_satisfies_a linear_recurrence_relation 
$$
2y_{k-1}-y_k+2y_{k+1}=0
$$ and_boundary conditions $y_0=y_{n+1}=-1$._And we are looking_for solutions satisfying_$y_k\ge_-1$.
Solving the recurrence by the standard method yields that
$$
 y_k = A\sin(k\alpha)+B\cos(k\alpha)
$$
for some constants_$A$_and $B$,_where_$\alpha=\arccos\frac14$._(This number comes from the_fact that the roots of_the equation_$2x^2-x+2=0$ are $\cos\alpha\pm i\sin\alpha$).
Since $y_0=-1$, we have $B=-1$._Then_$y_k=-1$ if and_only if 
$$
 A = A_k := \frac{\cos(k\alpha)-1}{\sin(k\alpha)} =_-\tan(k\alpha/2)
$$
So for the solution with $y_{n+1}=-1$_we have $A=A_{n+1}$,_and_the_relation $y_k\ge-1$ takes the_form
$$
\begin{cases}
 A_k \ge A_{n+1}, & A_{n+1}<0_\\
 A_k \le A_{n+1}, & A_{n+1}>0_
\end{cases}
$$
(note that $\tan(k\alpha/2)$ and $\sin(k\alpha)$ are of_the same sign).
So $n$ is included_in the sequence iff $A_{n+1}$_is either_the minimum of the positive_$A_k$'s, or the_maximum of_the negative $A_k$'s_($k=1,\dots,n+1$). Observe that the order of_$-A_k$'s in $\mathbb_R$ is the same as of_the_numbers $k\alpha\bmod 2\pi$_in_$(-\pi,\pi)$._So everything_ boils down_to_the