Tanya has $n$ candies numbered from $1$ to $n$. The $i$-th candy has the weight $a_i$.

She plans to eat exactly $n-1$ candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.

Your task is to find the number of such candies $i$ (let's call these candies good) that if dad gets the $i$-th candy then the sum of weights of candies Tanya eats in even days will be equal to the sum of weights of candies Tanya eats in odd days. Note that at first, she will give the candy, after it she will eat the remaining candies one by one.

For example, $n=4$ and weights are $[1, 4, 3, 3]$. Consider all possible cases to give a candy to dad:  Tanya gives the $1$-st candy to dad ($a_1=1$), the remaining candies are $[4, 3, 3]$. She will eat $a_2=4$ in the first day, $a_3=3$ in the second day, $a_4=3$ in the third day. So in odd days she will eat $4+3=7$ and in even days she will eat $3$. Since $7 \ne 3$ this case shouldn't be counted to the answer (this candy isn't good).  Tanya gives the $2$-nd candy to dad ($a_2=4$), the remaining candies are $[1, 3, 3]$. She will eat $a_1=1$ in the first day, $a_3=3$ in the second day, $a_4=3$ in the third day. So in odd days she will eat $1+3=4$ and in even days she will eat $3$. Since $4 \ne 3$ this case shouldn't be counted to the answer (this candy isn't good).  Tanya gives the $3$-rd candy to dad ($a_3=3$), the remaining candies are $[1, 4, 3]$. She will eat $a_1=1$ in the first day, $a_2=4$ in the second day, $a_4=3$ in the third day. So in odd days she will eat $1+3=4$ and in even days she will eat $4$. Since $4 = 4$ this case should be counted to the answer (this candy is good).  Tanya gives the $4$-th candy to dad ($a_4=3$), the remaining candies are $[1, 4, 3]$. She will eat $a_1=1$ in the first day, $a_2=4$ in the second day, $a_3=3$ in the third day. So in odd days she will eat $1+3=4$ and in even days she will eat $4$. Since $4 = 4$ this case should be counted to the answer (this candy is good). 

In total there $2$ cases which should counted (these candies are good), so the answer is $2$.


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of candies.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^4$), where $a_i$ is the weight of the $i$-th candy.


-----Output-----

Print one integer — the number of such candies $i$ (good candies) that if dad gets the $i$-th candy then the sum of weights of candies Tanya eats in even days will be equal to the sum of weights of candies Tanya eats in odd days.


-----Examples-----
Input
7
5 5 4 5 5 5 6

Output
2

Input
8
4 8 8 7 8 4 4 5

Output
2

Input
9
2 3 4 2 2 3 2 2 4

Output
3



-----Note-----

In the first example indices of good candies are $[1, 2]$.

In the second example indices of good candies are $[2, 3]$.

In the third example indices of good candies are $[4, 5, 9]$.

Difficulty: introductory

Starter code:

Solutions:
n=int(input())
arr=list(map(int,input().split()))
arr1=[]
arr2=[]
count1=0
count2=0
for i in range(n):
	if(i%2==0):
		count1+=arr[i]
	else:
		count2+=arr[i]
ans=0
temp1=0
temp2=0
for i in range(n):
	if(i%2==0):
		val1=temp1+count2-temp2
		val2=temp2+count1-temp1-arr[i]
		if(val1==val2):
			ans+=1
		temp1+=arr[i]
	else:
		val1=temp1+count2-temp2-arr[i]
		val2=temp2+count1-temp1
		if(val1==val2):
			ans+=1
		temp2+=arr[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = [0]
c = [0, 0]
for i in range(0, n, 2):
    b.append(b[-1] + a[i])
    b.append(b[-1])
    if (i + 1 < n):
        c.append(c[-1] + a[i + 1])
        c.append(c[-1])
#print(b)
#print(c)
ans = 0
for i in range(n):
    k1 = 0
    k2 = 0
    k1 += b[i] + c[n] - c[i + 1]
    k2 += c[i] + b[n] - b[i + 1]
    #print(i, k1, k2)
    if (k1 == k2):
        ans += 1
print(ans)

def mi():
    return list(map(int, input().split()))
'''
7
5 5 4 5 5 5 6
'''
n = int(input())
a = list(mi())

od = 0
ev = 0

for i in range(n):
    if i%2:
        od+=a[i]
    else:
        ev+=a[i]

cnt = 0
rod, rev = 0,0

for i in range(n-1,-1,-1):
    if i%2==0:
        ev-=a[i]
    else:
        od-=a[i]
    if ev+rev==od+rod:
        cnt+=1
    if i%2==0:
        rod+=a[i]
    else:
        rev+=a[i]
print (cnt)


n = int(input())
A = list(map(int, input().split()))
sum_left_odd = [0] * (n + 1)
sum_left_even = [0] * (n + 1)
sum_right_odd = [0] * (n + 1)
sum_right_even = [0] * (n + 1)
for i in range(n):
    if i % 2 == 0:
        sum_left_even[i] = sum_left_even[i - 1] + A[i]
        sum_left_odd[i] = sum_left_odd[i - 1]
    else:
        sum_left_even[i] = sum_left_even[i - 1]
        sum_left_odd[i] = sum_left_odd[i - 1] + A[i]

B = A[::-1]
for i in range(n):
    if i % 2 == 0:
        sum_right_even[i] = sum_right_even[i - 1] + B[i]
        sum_right_odd[i] = sum_right_odd[i - 1]
    else:
        sum_right_even[i] = sum_right_even[i - 1]
        sum_right_odd[i] = sum_right_odd[i - 1] + B[i]

answer = 0
for i in range(n):
    if n % 2:
        answer += int(sum_left_odd[i] + sum_right_even[n - i - 1] == sum_left_even[i] + sum_right_odd[n - i - 1])
    else:
        answer += int(sum_left_odd[i] + sum_right_odd[n - i - 1] == sum_left_even[i] + sum_right_even[n - i - 1])
print(answer)


n = int(input())
a = list(map(int, input().split()))
f1 = s1 = f2 = s2 = 0
for i in range(len(a)):
    if i % 2 == 0:
        f2 += a[i]
    else:
        s2 += a[i]
res = 0
z = (n - 1) % 2
for i in range(len(a)):
    if i % 2 == 0:
        f2 -= a[i]
        if f2 + s1 == s2 + f1:
            res += 1
        f1 += a[i]
    else:
        s2 -= a[i]
        if f2 + s1 == s2 + f1:
            res += 1
        s1 += a[i]
print(res)

n=int(input())
L=[int(i) for i in input().split()]
e=0
d=0
for i in range(n):
    if (i+1)%2==0:
        e+=L[i]
    else:
        d+=L[i]
s=0
e1=0
d1=0
#print(e, d)
for i in range(n-1, -1, -1):
    if (i+1)%2==0:
        e=e-L[i]
        if e+e1==d+d1:
            s+=1
        d1+=L[i]
    else:
        d=d-L[i]
        if e+e1==d+d1:
            s+=1
        e1+=L[i]
    #print(e, d, e1, d1)
print(s)


n = int(input().strip())
weights = list(map(int, input().strip().split()))

res = 0

sum_even = sum(weights[1::2])
sum_odd = sum(weights[2::2])

for idx in range(n):
    if sum_even == sum_odd:
        res += 1
    if idx == n-1:
        break
    if idx % 2 == 0:
        sum_even += weights[idx]
        sum_even -= weights[idx+1]
    else:
        sum_odd += weights[idx]
        sum_odd -= weights[idx+1]

print(res)


n = int(input())
arr = [int(x) for x in input().split()]
evens = [0]
odds = [0]
for i in range(len(arr)):
    if i % 2 == 0:
        evens.append(evens[-1] + arr[i])
    else:
        odds.append(odds[-1] + arr[i])
evens += [evens[-1]]
odds += [odds[-1]]
cnt = 0
for i in range(len(arr)):
    if i % 2 == 0:
        if evens[i//2] + (odds[-1] - odds[i//2]) == odds[i//2] + (evens[-1] - evens[i//2 + 1]):
            cnt += 1
    else:
        if evens[i//2 + 1] + (odds[-1] - odds[i//2 + 1]) == odds[i//2] + (evens[-1] - evens[i//2 + 1]):
            cnt += 1        
print(cnt)

n = int(input())
a = list(map(int, input().split()))


c = [0]
nc = [0]

fnc = sum(a[::2])
fc = sum(a[1::2])

chet = False

for s in a:

    if chet:
        c.append(c[-1] + s)
        nc.append(nc[-1])
    else:
        nc.append(nc[-1] + s)
        c.append(c[-1])

    chet = not chet

good = 0
for i in range(1, n+1):
    sum_chet = c[i-1] + fnc - nc[i]
    sum_nc = nc[i-1] + fc -c[i]
    if sum_chet == sum_nc:
        good+=1


print(good)


n = int(input())
a = list(map(int, input().split()))

s1 = sum(a[1::2])
s2 = sum(a[2::2])

#print(s1, s2)


r = 0
if s1 == s2:
    r+=1

for i, aa in enumerate(a[1:], 1):
    if i % 2 == 1:
        s1 -= a[i]
        s1 += a[i-1]
    else:
        s2 -= a[i]
        s2 += a[i-1]

    if s1 == s2:
        r += 1

print(r)


''' CODED WITH LOVE BY SATYAM KUMAR '''


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10**6) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10**9+7
import sys

class Operation:
    def __init__(self, name, function, function_on_equal, neutral_value=0):
        self.name = name
        self.f = function
        self.f_on_equal = function_on_equal
def add_multiple(x, count):
    return x * count
def min_multiple(x, count):
    return x
def max_multiple(x, count):
    return x
sum_operation = Operation("sum", sum, add_multiple, 0)
min_operation = Operation("min", min, min_multiple, 1e9)
max_operation = Operation("max", max, max_multiple, -1e9)
class SegmentTree:
    def __init__(self,
                 array,
                 operations=[sum_operation, min_operation, max_operation]):
        self.array = array
        if type(operations) != list:
            raise TypeError("operations must be a list")
        self.operations = {}
        for op in operations:
            self.operations[op.name] = op
        self.root = SegmentTreeNode(0, len(array) - 1, self)
    def query(self, start, end, operation_name):
        if self.operations.get(operation_name) == None:
            raise Exception("This operation is not available")
        return self.root._query(start, end, self.operations[operation_name])
    def summary(self):
        return self.root.values
    def update(self, position, value):
        self.root._update(position, value)
    def update_range(self, start, end, value):
        self.root._update_range(start, end, value)
    def __repr__(self):
        return self.root.__repr__()
class SegmentTreeNode:
    def __init__(self, start, end, segment_tree):
        self.range = (start, end)
        self.parent_tree = segment_tree
        self.range_value = None
        self.values = {}
        self.left = None
        self.right = None
        if start == end:
            self._sync()
            return
        self.left = SegmentTreeNode(start, start + (end - start) // 2,
                                    segment_tree)
        self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end,
                                     segment_tree)
        self._sync()
    def _query(self, start, end, operation):
        if end < self.range[0] or start > self.range[1]:
            return None
        if start <= self.range[0] and self.range[1] <= end:
            return self.values[operation.name]
        self._push()
        left_res = self.left._query(start, end,
                                    operation) if self.left else None
        right_res = self.right._query(start, end,
                                      operation) if self.right else None
        if left_res is None:
            return right_res
        if right_res is None:
            return left_res
        return operation.f([left_res, right_res])
    def _update(self, position, value):
        if position < self.range[0] or position > self.range[1]:
            return
        if position == self.range[0] and self.range[1] == position:
            self.parent_tree.array[position] = value
            self._sync()
            return
        self._push()
        self.left._update(position, value)
        self.right._update(position, value)
        self._sync()
    def _update_range(self, start, end, value):
        if end < self.range[0] or start > self.range[1]:
            return
        if start <= self.range[0] and self.range[1] <= end:
            self.range_value = value
            self._sync()
            return
        self._push()
        self.left._update_range(start, end, value)
        self.right._update_range(start, end, value)
        self._sync()
    def _sync(self):
        if self.range[0] == self.range[1]:
            for op in self.parent_tree.operations.values():
                current_value = self.parent_tree.array[self.range[0]]
                if self.range_value is not None:
                    current_value = self.range_value
                self.values[op.name] = op.f([current_value])
        else:
            for op in self.parent_tree.operations.values():
                result = op.f(
                    [self.left.values[op.name], self.right.values[op.name]])
                if self.range_value is not None:
                    bound_length = self.range[1] - self.range[0] + 1
                    result = op.f_on_equal(self.range_value, bound_length)
                self.values[op.name] = result
    def _push(self):
        if self.range_value is None:
            return
        if self.left:
            self.left.range_value = self.range_value
            self.right.range_value = self.range_value
            self.left._sync()
            self.right._sync()
            self.range_value = None
    def __repr__(self):
        ans = "({}, {}): {}\n".format(self.range[0], self.range[1],
                                      self.values)
        if self.left:
            ans += self.left.__repr__()
        if self.right:
            ans += self.right.__repr__()
        return ans

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def primeFactors(n): #n**0.5 complex 
    factors = dict()
    for i in range(2,math.ceil(math.sqrt(n))+1):  
        while n % i== 0: 
            if i in factors:
                factors[i]+=1
            else: factors[i]=1
            n = n // i 
    if n>2:
        factors[n]=1
    return (factors)

def binary(n,digits = 20):
    b = bin(n)[2:]
    b = '0'*(20-len(b))+b
    return b

def isprime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True
factorial_modP = []
def warm_up_fac(MOD):
    nonlocal factorial_modP,fac_warmup
    if fac_warmup: return
    factorial_modP= [1 for _ in range(fac_warmup_size+1)]
    for i in range(2,fac_warmup_size):
        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD
    fac_warmup = True

def InverseEuler(n,MOD):
    return pow(n,MOD-2,MOD)

def nCr(n, r, MOD):
    nonlocal fac_warmup,factorial_modP
    if not fac_warmup:
        warm_up_fac(MOD)
        fac_warmup = True
    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))
import heapq,itertools
pq = []                         # list of entries arranged in a heap
entry_finder = {}               # mapping of tasks to entries
REMOVED = '<removed-task>' 
def add_task(task, priority=0):
    'Add a new task or update the priority of an existing task'
    if task in entry_finder:
        remove_task(task)
    count = next(counter)
    entry = [priority, count, task]
    entry_finder[task] = entry
    heapq.heappush(pq, entry)

def remove_task(task):
    'Mark an existing task as REMOVED.  Raise KeyError if not found.'
    entry = entry_finder.pop(task)
    entry[-1] = REMOVED

def pop_task():
    'Remove and return the lowest priority task. Raise KeyError if empty.'
    while pq:
        priority, count, task = heapq.heappop(pq)
        if task is not REMOVED:
            del entry_finder[task]
            return task
    raise KeyError('pop from an empty priority queue')
memory = dict()
def clear_cache():
    nonlocal memory
    memory = dict()
def cached_fn(fn, *args):
    nonlocal memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result


# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
fac_warmup_size = 10**5+100
optimiseForReccursion = True #Can not be used clubbed with TestCases

def main():
    n = get_int()
    li = get_list()
    odd_sum = [0]
    even_sum = [0]
    for i,ele in enumerate(li):
        if i%2==0:
            even_sum.append(even_sum[-1]+ele)
            odd_sum.append(odd_sum[-1])
        else: 
            odd_sum.append(odd_sum[-1]+ele)
            even_sum.append(even_sum[-1])
    res = 0
    #print(odd_sum)
    #print(even_sum)
    for i in range(1,n+1):
        if even_sum[i-1]+odd_sum[-1]-odd_sum[i]==odd_sum[i-1]+even_sum[-1]-even_sum[i]:
            res+=1
    print(res)



# --------------------------------------------------------------------- END=


if TestCases: 
    for _ in range(get_int()): 
        cProfile.run('main()') if testingMode else main() 
else: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()

n=int(input())
a=list(map(int,input().split()))
b=[[0,0]]
e=o=0
for i in range(n):
    if i%2==0:
        o+=a[i]
    else:
        e+=a[i]
    b.append([e,o])
ans=0
#print(b)
for i in range(n):
    if i%2==0:
        o1=b[i][1]
        e1=b[i][0]
        o=b[-1][0]-e1+o1
        e=b[-1][1]-a[i]-o1+e1
    else:
        o1=b[i][1]
        e1=b[i][0]
        o=b[-1][0]-e1+o1-a[i]
        e=b[-1][1]-o1+e1
    if o==e:
        ans+=1
    #print(o,e,o1,e1,ans)
print(ans)


n = int(input())
A = [int(i) for i in input().split()]

ans = 0
S = [0, 0]

for i, a in enumerate(A):
    S[i%2] += a

S[0] -= A[0]
if S[0] == S[1]:
    ans += 1

for i in range(1, n):
    S[i%2] -= A[i]
    S[i%2] += A[i-1]
    if S[0] == S[1]:
        ans += 1

print(ans)

n=int(input())
l=list(map(int,input().split()))
if n==1:
	print(1)
else:
	left=[0 for i in range(n)]
	right=[0 for i in range(n)]
	left[0]=l[0]
	right[-1]=l[-1]
	left[1]=l[1]
	right[-2]=l[-2]
	for i in range(2,n):
		left[i]=left[i-2]+l[i]
	for i in range(n-3,-1,-1):
		right[i]=right[i+2]+l[i]

	ans=0
	for i in range(n):
		a=right[i+1] if i<n-1 else 0
		b=left[i-2] if i>=2 else 0
		lhs=a+b
		a=right[i+2] if i<n-2 else 0
		b=left[i-1] if i>=1 else 0
		rhs=a+b
		if lhs==rhs:
			ans+=1
	print(ans)

n = int(input())
a = list(map(int, input().split()))
sum1 = [0]
sum2 = [0]
for i in range(n):
    if i % 2 == 0:
        sum1.append(sum1[-1] + a[i])
        sum2.append(sum2[-1])
    else:
        sum2.append(sum2[-1] + a[i])
        sum1.append(sum1[-1])
ans = 0
for i in range(n):
    if i % 2 == 0:
        SUM1 = sum1[i]
        SUM2 = sum2[i]
        SUM1, SUM2 = SUM1 + sum2[-1] - SUM2, SUM2 + sum1[-1] - a[i] - SUM1
        if SUM1 == SUM2:
            ans += 1
    else:
        SUM1 = sum1[i]
        SUM2 = sum2[i]
        SUM1, SUM2 = SUM1 + sum2[-1] - a[i] - SUM2, SUM2 + sum1[-1] - SUM1
        if SUM1 == SUM2:
            ans += 1       
print(ans)

n = int(input())
l = [*map(int, input().split())]

e_pre, o_pre = [0], [0]
for i, e in enumerate(l):
    if i & 1:
        e_pre.append(e_pre[-1] + e)
        o_pre.append(o_pre[-1])
    else:
        o_pre.append(o_pre[-1] + e)
        e_pre.append(e_pre[-1])

o_pre.append(o_pre[-1])
e_pre.append(e_pre[-1])


res = 0

for i, ele in enumerate(l):
    e = e_pre[i] + (o_pre[-1] - o_pre[i + 1])
    o = o_pre[i] + (e_pre[-1] - e_pre[i + 1])
    if e == o:
        res += 1
print(res)

n=int(input())
a=[int(o) for o in input().split()]
sa=[0]*n
ea=[0]*(n+3)
oa=[0]*(n+3)
es=0
os=0
for i in range(n):
    if i%2==0:
        es+=a[i]
        sa[i]=es
        
    else:
        os+=a[i]
        sa[i]=os
    oa[i]=os
    ea[i]=es
count=0
for i in range(n):
    if i%2==0:
        if es-ea[i]+oa[i-1]==os-oa[i-1]+ea[i-1]:
            count+=1
    else:
        if os-oa[i]+ea[i-1]==es-ea[i-1]+oa[i-1]:
            count+=1
print(count)


n = int(input())
a = list(map(int, input().split()))
a = [0] + a
ch = [0, 0]
nech = [0, a[1]]

for i in range(2, n+1):
    if i % 2 == 0:
        ch.append(ch[i - 2] + a[i])
        nech.append(nech[-1])
    else:
        nech.append(nech[i - 2] + a[i])
        ch.append(ch[-1])

ans = 0
for i in range(1, n+1):
    s1 = nech[i-1]
    s2 = ch[i-1]
    s1 += ch[n] - ch[i]
    s2 += nech[n] - nech[i]
    if s1 == s2:
        ans += 1

print(ans)

n = int(input())
l = list(map(int, input().split()))
s1 = 0
s2 = 0
for i in range(1, n, 2):
    s1 += l[i]
for i in range(2, n, 2):
    s2 += l[i]
count = 0
if s1 == s2:
    count += 1
for i in range(1, n):
    if i % 2:
        s1 -= l[i]
        s1 += l[i-1]
    else:
        s2 -= l[i]
        s2 += l[i-1]
    if s1 == s2:
        count += 1
print(count)


n=int(input())
a=list(map(int,input().split()))
o=[a[0]]
e=[0]
for i in range(1,n):
	o.append(o[i-1] if i%2==1 else o[i-1]+a[i])
	e.append(e[i-1] if i%2==0 else e[i-1]+a[i])
#print(o,e)
c=0
for i in range(1,n):
	od=o[i]-a[i]+e[-1]-e[i-1]
	ev=e[i]-a[i]+o[-1]-o[i-1]
	#print(od,ev)
	if od==ev:
		c+=1
se=so=0
for i in range(n):
	se+=a[i] if i%2==1 else 0
	so+=a[i] if i%2==0 else 0
if se==so-a[0]:
	c+=1
print(c)


n = int(input())
a = input().split()
a = [int(i) for i in a]
odd = []
even = []
s1 = 0
s2 = 0
for i in range(n):
    if i % 2 == 0:
        s1 += a[i]
        odd.append(s1)
        even.append(s2)
    else:
        s2 += a[i]
        odd.append(s1)
        even.append(s2)
ans = 0
for i in range(n):
    if i % 2 == 0:
        if odd[i] - a[i] + even[n - 1] - even[i] == even[i] + odd[n - 1] - odd[i]:
            ans += 1
    else:
        if even[i] - a[i] + odd[n - 1] - odd[i] == odd[i] + even[n - 1] - even[i]:
            ans += 1
print(ans)

n=int(input())
kon=[int(x) for x in input().split()]
h=n=0
i=1
for item in kon:
    if i%2==0:
        h+=item
    else:
        n+=item
    i+=1
n1=h1=0
counter=0
k=1
for item in kon:
    if k%2==0:
        i=h-h1-item+n1
        j=n-n1+h1
        h1+=item
    else:
        i=h-h1+n1
        j=n-n1+h1-item
        n1+=item
    if i==j:
        counter+=1
    k+=1
print(counter)