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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdint.h>
#include <unordered_set>
#include <algorithm>
#include <vector>
#include <functional>


using namespace std;


static const int32_t DIVISOR = 1000000007;


struct Elem
{
    bool    fKnown;
    int32_t iNum;
    int64_t iResult;
};


static int32_t iN;

static int64_t iTotal;

static Elem aElems[300000];


static void ReadData()
{
    int32_t k;

    iTotal = 0;

    cin >> iN;

    for (int i = 0; i < iN; ++i)
    {
        aElems[i].fKnown = false;
        
        cin >> k;

        aElems[i].iNum = k;

        iTotal += k;
    }
}


static inline void IncreaseModulo(int64_t & iSum, int64_t iIncrement)
{
    iSum += iIncrement;

    if (iSum >= DIVISOR)
    {
        iSum -= DIVISOR;
    }
}


static int64_t Recursive(int32_t iPos)
{
    if (iPos == iN)
        return 1;

    if (aElems[iPos].fKnown)
    {
        return aElems[iPos].iResult;
    }

    int64_t & iResult = aElems[iPos].iResult;

    iResult = 0;

    int64_t iSum = 0;

    for (int i = iPos; i < iN; ++i)
    {
        IncreaseModulo(iSum, aElems[i].iNum);

        if ((iSum & 1) == 0)
        {
            IncreaseModulo(iResult, Recursive(i + 1));
        }
    }

    aElems[iPos].fKnown = true;

    return iResult;
}


static int64_t SimpleCase()
{
    if ((iTotal & 1) == 1)
    {
        return 0;
    }

    int32_t iSum = 0;
    int32_t iCnt = 0;

    for (int i = 0; i < iN; ++i)
    {
        iSum += aElems[i].iNum;

        if ((iSum & 1) == 0)
        {
            iCnt++;
        }
    }

    int64_t iRes = 1;

    for (int i = 0; i < iCnt - 1; ++i)
    {
        iRes = (iRes << 1) % DIVISOR;
    }

    return iRes;
}


int main(int argc, char * argv[])
{
    ReadData();

    int64_t iResult;

    if (iTotal < DIVISOR)
    {
        iResult = SimpleCase();
    }
    else
    {
        iResult = Recursive(0);
    }

    cout << iResult;

    return 0;
}