Iahub accidentally discovered a secret lab. He found there *n* devices ordered in a line, numbered from 1 to *n* from left to right. Each device *i* (1 ≤ *i* ≤ *n*) can create either *a*<sub class="lower-index">*i*</sub> units of matter or *a*<sub class="lower-index">*i*</sub> units of antimatter. 

Iahub wants to choose some contiguous subarray of devices in the lab, specify the production mode for each of them (produce matter or antimatter) and finally take a photo of it. However he will be successful only if the amounts of matter and antimatter produced in the selected subarray will be the same (otherwise there would be overflowing matter or antimatter in the photo). 

You are requested to compute the number of different ways Iahub can successful take a photo. A photo is different than another if it represents another subarray, or if at least one device of the subarray is set to produce matter in one of the photos and antimatter in the other one.
The first line contains an integer *n* (1 ≤ *n* ≤ 1000). The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1000).

The sum *a*<sub class="lower-index">1</sub> + *a*<sub class="lower-index">2</sub> + ... + *a*<sub class="lower-index">*n*</sub> will be less than or equal to 10000.
from sys import stdin, stdout

MOD = 10**9 + 7

def solve(A, n):
    assert n ==  len(A)

    # calculate prefix sum
    ps = prefix_sum(A)
    # calculate suffix sum
    ss = suffix_sum(A)
    
    # total sum
    ST = ps[-1]
    # count ways of bipartite A with equal sum
    count = 0
    # iterate over each subarray
    for sub, i, j in subarrays(A):
        # take sum of subarray
        M = ST - ps[i] - ss[j + 1]
        # if sum of subarray is even then calculate dp
        if not M % 2:
            count += calculate_photos(sub, M)
    return count % MOD

def prefix_sum(A):
    # this method calculate the prefix sum of the array, ps[i] is the sum of the elements in [0, i)
    ps = [0] * (len(A) + 1)
    for i in range(1, len(A) + 1):
        ps[i] = ps[i - 1] + A[i-1]
    return ps

def suffix_sum(A):
    # this method calculate the suffix sum of the array, ss[i] is the sum of the elements in (i, n-1]
    ss = [0] * (len(A) + 1)
    for i in range(n-1,-1,-1):
        ss[i] = ss[i + 1] + A[i]
    return ss

def subarrays(A):
    # this method calculate all the subarray of lenght >=2
    for i in range(n):
        for j in range(i + 1, n):
            yield A[i:j + 1], i, j

def calculate_photos(A, S):
    # this method calculate the number of ways of bipartite A with equal sum S
    dp = [[0] * (S + 1) for _ in range(len(A) + 1)]
    # how many photo can take end in elemnt i with sum 0, just 1 with empty subset
    for i in range(len(A)):
        dp[i][0] = 1
    for i in range(1, len(A) + 1):
        for j in range(1, S + 1):
            # dont take element i in subset
            dp[i][j] = dp[i - 1][j]
            # take element i in subset if it is possible
            if A[i - 1] <= j:
                dp[i][j] += dp[i-1][j - A[i-1]]
    # then return dp[n][S/2]
    return dp[len(A)][S//2] 



if __name__ == "__main__":
    n = int(stdin.readline().split()[0])
    A = [*map(int, stdin.readline().split())]
    stdout.write(str(solve(A, n))+"\n")