The answer is 2⋅3n−2n.
Let yj=x2j−1+x2j for j=1,2,…,n. Every desired sequence {xj} corresponds to a sequence {yj} such that yj=−2,0,2 for each j, and ∣yk+yk+1+⋯+ym∣≤2 for any 1≤k≤m≤n. Suppose there are r terms of {yj} which are nonzero, say yi1,yi2,…,yir where i1<i2<⋯<ir. Since
∣yi1+yi1+1+⋯+yi2∣=∣yi1+yi2∣≤2,
we must have yi2=−yi1. Similarly, yi3=−yi2=yi1, and inductively yi2j−1=yi1 and yi2j=−yi1 for any integer j. In other words, the sequence {yj} only depends on the indices i1,i2,…,ir and the term yi1.
Conversely, for any such sequence {yj}, consider any 1≤k≤m≤n. Let is be the smallest index such that k≤is, and let it be the largest index such that it≤m. Then
yk+yk+1+⋯+ym=yis+yis+1+⋯+yit=±(2−2+2−2+…)=−2,0,2.
So the condition is satisfied.
Now, for each sequence {yj} satisfying the condition, we can construct the sequence {xj} as follows. For any index j of the form iu, the terms x2j−1 and x2j are uniquely determined. Indeed, if yiu=±2, then x2iu−1=x2iu=±1. For any other index j, there are two choices for x2j−1 and x2j, since exactly one of them is 1 and the other is -1. Since there are (rn) ways to choose the indices i1,i2,…,ir and two ways to choose yi1 if r≥1, the total number of sequences is
(0n)2n+r=1∑n2(rn)⋅2n−r=2n+2r=1∑n(n−rn)2n−r=2n+2d=0∑n−1(dn)2d
using the change of variable d=n−r. By the binomial theorem, this is equal to
2n+2d=0∑n(dn)2d−2n+1=2n+2(2+1)n−2n+1=2⋅3n−2n.