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

const int mod = 1e9+7;

int n, q[100005];
int prime[1000005];
int dp[100005];

signed main(){
  
  for(int i=0;i<1000005;i++) prime[i] = 1;
  
  prime[0] = prime[1] = 0;
  
  for(int i=1;i*i<1000005;i++){

    if(prime[i]==0) continue;
    
    for(int j=i*2;j<1000005;j+=i) prime[j] = 0;
    
  }
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>q[i];
  
  dp[0] = 1;
  
  for(int i=0;i<n;i++){
    
    if( prime[q[i]] == 0 ) continue;
    
    if( i == n-1 ){
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
      continue;
    }
    
    if(q[i]<q[i+1]){
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
    }
    
    if( i+2 == n ){
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
    else if(q[i]<q[i+2]){
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
    
  }

  cout<<dp[n]<<endl;
  
  return 0;
}

