#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
namespace std {
#ifndef LOCAL
#define cerr \
if (0) cerr
#endif
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://x...content-available-to-author-only...i.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
} // namespace std
const int64_t MOD = 113127131137139149LL;
const int N = 3e5 + 5;
int64_t add(int64_t a, int64_t b) {
a += b;
if (a >= MOD) a -= MOD;
if (a < 0) a += MOD;
return a;
}
int64_t cal(int x) {
int64_t a = 2;
int64_t ans = 1;
while (x > 0) {
if (x & 1) {
ans = __int128_t(ans) * a % MOD;
}
a = __int128_t(a) * a % MOD;
x >>= 1;
}
return ans;
}
int a[N];
int64_t pref[N];
int dp[N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
#define task "a"
#else
#define task ""
#endif
if (fopen(task ".inp", "r")) {
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
pref[i] = (pref[i - 1] + cal(a[i])) % MOD;
}
vector<int64_t> cand;
for (int i = 1; i <= n; i++) {
int64_t cur = cal(a[i]);
for (int j = 0; (1 << j) <= n; j++) {
// pref[i] - ? = cur
// pref[i] - cur = ?
cand.emplace_back(cur);
cur += cur;
if (cur >= MOD) cur -= MOD;
}
}
sort(cand.begin(), cand.end());
cand.resize(unique(cand.begin(), cand.end()) - cand.begin());
gp_hash_table<int64_t, int> sum;
dp[0] = 1;
sum[pref[0]] = 1;
const int m = 1e9 + 7;
for (int i = 1; i <= n; i++) {
int64_t cur = cal(a[i]);
for (auto cur : cand) {
int64_t need = pref[i] - cur; if (need < 0) need += MOD;
if (sum.find(need) != sum.end()) {
dp[i] += sum[need];
if (dp[i] >= m) dp[i] -= m;
}
}
sum[pref[i]] += dp[i];
if (sum[pref[i]] >= m) sum[pref[i]] -= m;
}
cout << dp[n];
return 0;
}