#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-12;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
inline T sq(T a) {
  return a * a;
}
long long int in() {
  long long int x;
  scanf("%lld", &x);
  return x;
}
char yuyushiki[1000010];
string stin() {
  scanf("%s", yuyushiki);
  return yuyushiki;
}
struct Mod {
  unsigned n;
  Mod() : n(0) {}
  Mod(long long int x) {
    if (x < 0)
      n = x % MOD + MOD;
    else
      n = x % MOD;
  }
};
Mod operator+(Mod a, Mod b) { return Mod(a.n + b.n); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-(Mod a) { return Mod(MOD - a.n); }
Mod operator-(Mod a, Mod b) { return Mod(a.n + MOD - b.n); }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*(Mod a, Mod b) { return Mod((long long int)a.n * b.n); }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod modpow(Mod x, long long int k) {
  Mod res = 1;
  while (k) {
    if (k & 1) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
long long int extgcd(long long int a, long long int b, long long int &x,
                     long long int &y) {
  long long int d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv(Mod a) {
  long long int x, y;
  assert(extgcd(a.n, MOD, x, y) == 1);
  return Mod(x);
}
Mod operator/(Mod a, Mod b) { return Mod((long long int)a.n * inv(b).n); }
Mod operator/=(Mod &a, Mod b) { return a = a / b; }
vector<int> ps;
vector<bool> isp;
int max_p;
void init_p(int mp = 1000010) {
  max_p = mp;
  isp.resize(max_p, true);
  isp[0] = isp[1] = false;
  for (long long int i = (2); i < (long long int)(max_p); i++) {
    if (isp[i]) {
      ps.emplace_back(i);
      for (int j = i * 2; j < max_p; j += i) isp[j] = false;
    }
  }
}
bool is_prime(int x) {
  if (max_p <= x) init_p(x + 1);
  return isp[x];
}
int n;
int a[100010];
Mod dp[100010][2];
int main() {
  n = in();
  a[0] = -1;
  for (long long int i = (0); i < (long long int)(n); i++) {
    a[i + 1] = in();
  }
  dp[0][0] = 1;
  for (long long int i = (0); i < (long long int)(n); i++) {
    for (long long int j = (0); j < (long long int)(2); j++) {
      if (dp[i][j].n != 0) {
        if (a[i - j] < a[i + 1] && is_prime(a[i + 1])) {
          dp[i + 1][0] += dp[i][j];
          if (i + 2 <= n && a[i + 2] >= 2) {
            dp[i + 2][1] += dp[i][j];
          }
        }
      }
    }
  }
  Mod ans = dp[n][0] + dp[n][1];
  cout << ans.n << endl;
  return 0;
}
