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

void eratosthenes(int N, int* arr){
  for(int i=0; i < N; i++){
    arr[i] = 1;
  }
  for(int i=2; i < sqrt(N); i++){
    if(arr[i]){
      for(int j=0; i * (j + 2) < N; j++){
        arr[i*(j+2)] = 0;
      }
    }
  }
}

int main(void){
  const int NMAX = 100011;
  const int QMAX = 1000001;
  const int MOD = 1e9+7;
  int dp[NMAX][2]; // dp[idx][自分が素因数(0)か肩(1)か]
  int isprime[QMAX];
  for(int i = 0; i < NMAX; i++) for(int j = 0; j < 2; j++) dp[i][j] = 0;
  eratosthenes(QMAX, isprime);



  int N; cin >> N;
  vector<int> q(N);
  for(int i = 0; i < N; i++) cin >> q[i];
  q.push_back(0);

  if(isprime[q[0]])
    dp[0][0] = 1;

  for(int i = 0; i < N-1; i++){
    for(int j = 0; j < 2; j++){
      if(j == 0){
        dp[i+1][1] = (dp[i+1][1] + dp[i][j]) % MOD;
        if(q[i+1] > q[i] && isprime[q[i+1]]){
          dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % MOD;
        }
      }else{
        if((i == 0 || q[i+1] > q[i-1]) && isprime[q[i+1]]){
          dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % MOD;
        }
      }
    }
  }
  cout << (dp[N-1][0] + dp[N-1][1]) % MOD << endl;
  return 0;
}

