#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

bool isprime(int x){
    for (int y = 2; y * y <= x; y++){
        if (x % y == 0) return false;
    }
    return true;
}

const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in();

    VI isp(n);
    REP(i,n) isp[i] = isprime(a[i]);

    VVI dp(n+2, VI(2));
    if (isp[0]){
        dp[1][0] = 1;
        dp[2][1] = 1;
    }

    FOR(i,1,n-1) REP(j,2){
        if (!isp[i]) continue;
        if (a[i] <= a[i-j-1]) continue;
        dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % mod;
        dp[i+2][1] = (dp[i+2][1] + dp[i][j]) % mod;
    }

    cout << (dp[n][0] + dp[n][1]) % mod << endl;

    return 0;
}
