#include <bits/stdc++.h>
using namespace std;
const int INF =
    sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
int n;
int q[100010];
vector<bool> sosu;
vector<bool> eratosthenes(int n) {
  vector<bool> prime(n + 1, true);
  prime = vector<bool>(n + 1, true);
  if (n >= 0) prime[0] = false;
  if (n >= 1) prime[1] = false;
  for (int i = 2; i * i <= n; i++)
    if (prime[i])
      for (int j = i * 2; j < n; j += i) prime[j] = false;
  return prime;
}
long long solve(int i = 0, int prevSosu = 1, int prevIsE = true) {
  int pear = 1, berry = 1;
  bool flaga = false, flagb = false;
  if (i == n) {
    return 1;
  }
  if (sosu[q[i]] && prevSosu < q[i]) {
    pear *= solve(i + 1, q[i], false);
    flaga = true;
  }
  if (!prevIsE) {
    berry *= solve(i + 1, prevSosu, true);
    flagb = true;
  }
  pear *= flaga;
  berry *= flagb;
  return pear + berry;
}
signed main() {
  cin >> n;
  for (auto i = 0; i < n; i++) cin >> q[i];
  sosu = eratosthenes(1000000);
  cout << solve() << endl;
  return 0;
}
