#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int M = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> q(N);
    vector<bool> b(N, false);
    for(int i = 0; i < N; ++i) {
        cin >> q[i];
        for(int x = 2; x * x <= q[i]; ++x) {
            if(q[i] % x == 0) b[i] = true;
        }
    }

    // dp[i][pre is p]
    vector<vector<int>> dp(N + 1, vector<int>(2));
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i) {
        if(i == 0 && !b[i]) {
            dp[i + 1][1] = 1;
            continue;
        }
        for(int j = 0; j < 2; ++j) {
            if(j == 0) {
                if((i < 2 || (q[i - 2] != q[i] && q[i - 2] < q[i]))
                    && !b[i]) {
                    (dp[i + 1][1] += dp[i][j]) %= M;
                }
            } else { // pre is p
                if(q[i - 1] == q[i]) {
                    (dp[i + 1][0] += dp[i][j]) %= M;
                } else {
                    if(q[i - 1] < q[i] && !b[i]) {
                        (dp[i + 1][1] += dp[i][j]) %= M;
                    }
                    (dp[i + 1][0] += dp[i][j]) %= M;
                }
            }
        }
    }
    int ans = (dp[N][0] + dp[N][1]) % M;
    cout << ans << endl;
}

