#include <bits/stdc++.h>

using namespace std;

using ll=long long;

bool isprime(int num){
  if(num<2)return false;
  else if(num==2)return true;
  else if(num % 2 == 0)return false;

  int sqrtnum=sqrt(num);
  for(int i=3;i<=sqrtnum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  ll q[100001]={0};
  for(int i=0;i<n;++i){
    cin>>q[i];
  }
  ll dp[100001]={0};
  if(isprime(q[0]))dp[0]=1;
  if(isprime(q[1]))if(dp[0]==1 && q[0]<q[1])dp[1]=1;
  for(int i=2;i<n;++i){
    if(!isprime(q[i]))continue;
    if(q[i-1]<q[i])dp[i]+=dp[i-1];
    if(q[i-2]<q[i])dp[i]+=dp[i-2];
    dp[i]%=1000000007;
  }
  if(n==1)cout<<dp[0]<<endl;
  else cout<<(dp[n-2]+dp[n-1])%1000000007<<endl;
}
