#include <bits/stdc++.h>
using namespace std;
constexpr int N = 3e5 + 1, exps[]{37, 11, 9, 8, 7, 5};
using E = array<uint64_t, size(exps)>;
constexpr uint64_t mod = -49ull / 2;
template <typename V>
struct umap {
vector<uint64_t> keys;
vector<V> vals;
vector<uint32_t> nx;
vector<uint32_t> head;
int cap{};
int geti(uint64_t k) {
reserve();
for (int i = head[k & cap]; ~i; i = nx[i]) if (keys[i] == k) return i;
nx.push_back(head[k & cap]);
head[k & cap] = keys.size();
keys.push_back(k);
vals.push_back({});
return vals.size() - 1;
}
void reserve() {
if (keys.size() * 2 < cap) return;
cap = max(cap * 2 + 1, 6);
head.assign(cap + 1, -1);
nx.clear();
for (int i = 0; i < keys.size(); ++i) {
nx.push_back(head[keys[i] & cap]);
head[keys[i] & cap] = i;
}
}
};
template <int i>
struct um: conditional_t<i == size(exps), vector<int>, umap<um<i + 1>>> { };
um<0> m;
vector<int> ls[N];
template <int i = 0>
auto& mget(const E& e, auto& m) {
if constexpr (i == size(exps)) return m;
else return mget<i + 1>(e, m[e[i]]);
}
template <int i = 0>
void walk(const E& e, auto& m, uint64_t k, uint64_t pr, auto f) {
if constexpr (i == size(exps)) f(m, k, pr);
else {
uint64_t step = pr;
while (step % exps[i] != 1) step += pr;
while (k % exps[i]) k += pr;
pr *= exps[i];
if (m.size() != 1)
for (int j = 0; j < exps[i]; ++j) {
auto it = m.find((e[i] + (1ull << exps[i]) - 1 - (1ull << j)) % ((1ull << exps[i]) - 1));
if (it != m.end()) walk<i + 1>(e, it->second, k, pr, f);
k = (k + step) % pr;
}
else if (auto& [ke, v] = *m.begin(); 1)
for (int j = 0; j < exps[i]; ++j) {
if ((e[i] + (1ull << exps[i]) - 1 - (1ull << j)) % ((1ull << exps[i]) - 1) == ke) walk<i + 1>(e, v, k, pr, f);
k = (k + step) % pr;
}
}
}
int dp[N];
uint64_t pw[(int)1.1e6];
uint64_t pss[N];
int main() {
cin.tie(0)->sync_with_stdio(0);
pw[0] = 1;
for (uint64_t i = 1, p = 2; i < size(pw); ++i) pw[i] = p, p = (p + p) % mod;
int n; cin >> n;
E ps{};
uint64_t psm{};
for (int i = 0; ; ++i) {
mget(ps, m).push_back(i);
walk(ps, m, 0, 1, [&](auto& v, auto k, auto p) { for (auto& j: v) if (pss[j] == (psm + mod - pw[k]) % mod) ls[i].push_back(j); });
pss[i] = psm;
if (i == n) break;
int v; cin >> v;
for (int j = 0; j < size(exps); ++j) ps[j] = (ps[j] + (1ull << v % exps[j])) % ((1ull << exps[j]) - 1);
psm = (psm + pw[v]) % mod;
}
dp[0] = 1;
for (int i = 1; i <= n; ++i)
for (auto j: ls[i]) dp[i] = (dp[i] + dp[j]) % ((int)1e9 + 7);
cout << dp[n];
}