/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */
#include <cstdint>
#include <iostream>
#include <string>
#include <algorithm>

constexpr int32_t kMaxValueArraySize = 200000;
constexpr int32_t kMaxPrimeArraySize = 50000;

void CallPrimeNumber(std::istream &input_stream);

class PrimeNumber {
 public:
  PrimeNumber() noexcept;
  ~PrimeNumber() noexcept;
  void AddData(const int32_t value);
  void ResetData() noexcept;
  int32_t CalculateNumberOfPrimes() noexcept;
  void CalculateMaxSearchTarget();
  void CalculatePrimeTable();
  bool IsPrime(const int32_t value) const;

 private:
  PrimeNumber(const PrimeNumber &obj) noexcept = delete;
  PrimeNumber &operator=(const PrimeNumber &obj) noexcept = delete;
  PrimeNumber(PrimeNumber &&obj) = delete;
  PrimeNumber &operator=(PrimeNumber &&obj) = delete;

 private:
  int32_t size_;
  int32_t values_[kMaxValueArraySize];
  int32_t number_of_primes_;
  int32_t primes_[kMaxPrimeArraySize];
  int32_t max_search_target_;
};

void CallPrimeNumber(std::istream &input_stream) {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  PrimeNumber *prime_number = new PrimeNumber();
  try {
    int32_t count;
    input_stream >> count;
    for (int32_t index = 0; index < count; ++index) {
      int32_t cvalue;
      input_stream >> cvalue;
      prime_number->AddData(cvalue);
    }
    std::cout << prime_number->CalculateNumberOfPrimes() << std::endl;
  } catch (...) {
    std::cout << "ERROR: CallPrimeNumber()" << std::endl;
    throw;
  }
  delete prime_number;
}

// ****************************************************

PrimeNumber::PrimeNumber() noexcept : size_(0), values_{}, number_of_primes_(1), primes_{}, max_search_target_(0) {
  primes_[0] = 2;
}
PrimeNumber::~PrimeNumber() noexcept {}

void PrimeNumber::AddData(const int32_t value) {
  if (size_ >= kMaxValueArraySize) {
    std::cout << "ERROR: AddData(): Data size exceeded a limit = " << kMaxValueArraySize << std::endl;
    throw 1;
  }
  values_[size_] = value;
  size_++;
}

int32_t PrimeNumber::CalculateNumberOfPrimes() noexcept {
  int32_t count = 0;
  try {
    CalculateMaxSearchTarget();
    CalculatePrimeTable();
    for (int32_t index = 0; index < size_; ++index) {
      if (IsPrime(values_[index])) {
        ++count;
      } else {
        // DO NOTHING
      }
    }
  } catch (...) {
    std::cout << "ERROR: CalculatePrimeNumber()" << std::endl;
    throw;
  }
  return count;
}

void PrimeNumber::ResetData() noexcept {
  size_ = 0;
  number_of_primes_ = 0;
  max_search_target_ = 0;
}

void PrimeNumber::CalculateMaxSearchTarget() {
  try {
    max_search_target_ = 0;
    for (int32_t index = 0; index < size_; ++index) {
      max_search_target_ = std::max(max_search_target_, values_[index]);
    }
    const float temp = std::sqrt(static_cast<float>(max_search_target_));
    max_search_target_ = static_cast<int32_t>(std::ceil(temp));
  } catch (...) {
    std::cout << "ERROR: CalculateMaxSearchTarget()" << std::endl;
    throw;
  }
}

void PrimeNumber::CalculatePrimeTable() {
  try {
  for (int32_t target = 3; target <= max_search_target_; target += 2) {
    if (IsPrime(target)) {
      const int32_t index_to_store = number_of_primes_;
      if (index_to_store >= kMaxPrimeArraySize) {
        std::cout << "ERROR: CalculatePrimeTable(): The number of primes exceeded a limit: " << size_ << std::endl;
        throw 1;
      } else {
        primes_[index_to_store] = target;
        ++number_of_primes_;
      }
    }
  }
  } catch(...) {
    std::cout << "ERROR: CalculatePrimeTable()" << std::endl;
    throw;
  }
}

bool PrimeNumber::IsPrime(const int32_t value) const {
  bool is_prime = true;
  if (std::sqrt(value) > static_cast<float>(max_search_target_ + 1) || value < 0) {
    std::cout << "ERROR: IsPrime(): value is out of range: " << value << std::endl;
    throw 1;
  } else if ((value == 0) || (value == 1)) {
    is_prime = false;
  } else {
    for (int32_t index_prime = 0; index_prime < number_of_primes_; ++index_prime) {
      const int32_t cprime = primes_[index_prime];
      if ((value != cprime) && ((value % cprime) == 0)) {
        is_prime = false;
        break;
      }
    }
  }
  return is_prime;
}

int main(int argc, char *argv[]) {
  try {
    CallPrimeNumber(std::cin);
  } catch (...) {
    std::cout << "ERROR: main()" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3768