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
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define mod 1000000007
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
using namespace std;
const int maxn = 500005;
int a[maxn];

struct bit {
    int d[maxn];
    int lb(int x) {
        return x & -x;
    }
    void upd(int a, int b) {
        while (a < maxn) {
            d[a] = (d[a] + b) % mod;
            a += lb(a);
        }
    }
    int q(int a) {
        int ans = 0;
        while (a) {
            ans = (ans + d[a]) % mod;
            a -= lb(a);
        }
        return ans;
    }
    int q(int l, int r) {
        return (q(r) - q(l - 1)) % mod;
    }
}x[2];
int n;
int b[maxn];
ll dp[maxn];
int main() {   
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]), 
        a[i] = (a[i] + a[i - 1]) % mod;
    vi cur;
    for (int i = 0; i <= n; i++)
        cur.pb(a[i]);
    sort(cur.begin(), cur.end());
    for (int i = 0; i <= n; i++)
        b[i] = lower_bound(cur.begin(), cur.end(), a[i]) - cur.begin() + 1;
    for (int i = 0; i <= n; i++) {
        if (i) {
            int tp = a[i] % 2;
            dp[i] = x[tp ^ 1].q(b[i] + 1, maxn - 1) + x[tp].q(1, b[i]);
            dp[i] %= mod;
        }
        else dp[i] = 1;
        x[a[i] % 2].upd(b[i], dp[i]);
    }
    int ans = dp[n];
    ans = (ans % mod + mod) % mod;
    cout << ans << endl;
    return (0-0); // <3 cxr
}
/*
4 1000000006 1 5 1000000004
*/