1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

typedef long long unsigned int ll;

/*

4
1000000006 1 5 1000000004

3
1000000006 1 5

2
2 2

3
6 1 5

3
2 2 2



*/

constexpr int MOD = 1000000007;

bool is_mopa_number(ll num)
{
    return !((num%MOD)&1);
}

int n;
vector<int> a;

ll solve_exp(int pos=0)
{
    ll result=0;
    ll sum=0;
    while(pos<n)
    {
        sum+=a[pos++];
        if(!((sum%MOD)&1))
        {
            result+=(pos==n?1:solve_exp(pos));
            result=result%MOD;
        }
    }
    return result;
}

int main()
{
    cin>>n;
    a.resize(n);
    ll sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<MOD) //O(n)
    {
        ll res[2];
        res[0]=(a[0]&1)?0:1;
        res[1]=1-res[0];
        for(int i=1;i<n;++i)
        {
            ll new_res[2];
            if(a[i]&1)
            {
                new_res[0]=res[1]*2;
                new_res[1]=res[0];
            }
            else
            {
			    new_res[0]=res[0]*2;
			    new_res[1]=res[1];
            }
            res[0]=new_res[0]%MOD;
            res[1]=new_res[1]%MOD;
        }
        cout<<res[0];
    }
    else
    {
        cout<<solve_exp();
    }
#if 0
    else
    {
        unordered_map<ll,ll> ms[2];
        ms[0][a[0]]=(a[0]&1)?0:1;
        for(int i=1;i<n;++i)
        {
            const ll num=a[i];
            const auto& prev_m=ms[1-(i&1)];
            auto& curr_m=ms[i&1];
            curr_m.clear();
            for(const auto& p : prev_m)
            {
				const ll new_num=(p.first+num)%MOD;
                const bool is_new_num_mopa=!(new_num&1);

                if(is_new_num_mopa&&is_mopa_number(p.first)==is_mopa_number(num))
                    curr_m[new_num]=(p.second*2)%MOD;
                else
                    curr_m[new_num]=p.second;
            }
        }
        ll result=0;
        auto& result_m=ms[1-(n&1)];
        for(const auto& p : result_m)
            if(is_mopa_number(p.first))
                result+=p.second%MOD;
        cout<<result;
    }
#endif
    return 0;
}