func_code_string: #include <bits/stdc++.h>   template <typename T>   class IntegerIterator       : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {    public:     explicit IntegerIterator(T value) : value(value) {}     IntegerIterator& operator++() {       ++value;       return *this;     }     IntegerIterator operator++(int) {       IntegerIterator copy = *this;       ++value;       return copy;     }     IntegerIterator& operator--() {       --value;       return *this;     }     IntegerIterator operator--(int) {       IntegerIterator copy = *this;       --value;       return copy;     }     T operator*() const { return value; }     bool operator==(IntegerIterator rhs) const { return value == rhs.value; }     bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); }       private:     T value;   };   template <typename T>   class IntegerRange {    public:     IntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }     IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); }     IntegerIterator<T> end() const { return IntegerIterator<T>(end_); }       private:     T begin_;     T end_;   };   template <typename T>   class ReversedIntegerRange {     using IteratorType = std::reverse_iterator<IntegerIterator<T>>;       public:     ReversedIntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }     IteratorType begin() const {       return IteratorType(IntegerIterator<T>(begin_));     }     IteratorType end() const { return IteratorType(IntegerIterator<T>(end_)); }       private:     T begin_;     T end_;   };   template <typename T>   IntegerRange<T> range(T to) {     return IntegerRange<T>(0, to);   }   template <typename T>   IntegerRange<T> range(T from, T to) {     return IntegerRange<T>(from, to);   }   template <typename T>   IntegerRange<T> inclusiveRange(T to) {     return IntegerRange<T>(0, to + 1);   }   template <typename T>   IntegerRange<T> inclusiveRange(T from, T to) {     return IntegerRange<T>(from, to + 1);   }   template <typename T>   ReversedIntegerRange<T> downrange(T from) {     return ReversedIntegerRange<T>(from, 0);   }   template <typename T>   ReversedIntegerRange<T> downrange(T from, T to) {     return ReversedIntegerRange<T>(from, to);   }   template <typename T>   ReversedIntegerRange<T> inclusiveDownrange(T from) {     return ReversedIntegerRange<T>(from + 1, 0);   }   template <typename T>   ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {     return ReversedIntegerRange<T>(from + 1, to);   }   std::vector<int> linearSieve(int maxN) {     ;     std::vector<int> leastPrimes(maxN + 1);     std::vector<int> primes;     for (int i = 2; i <= maxN; ++i) {       if (leastPrimes[i] == 0) {         leastPrimes[i] = i;         primes.push_back(i);       }       for (int prime : primes) {         if (i * prime > maxN) {           break;         }         leastPrimes[i * prime] = prime;       }     }     return leastPrimes;   }   template <typename T>   T gcd(T a, T b) {     while (b) {       T tmp = a % b;       a = b;       b = tmp;     }     return a;   }   template <typename R>   void sort(R& range) {     std::sort(range.begin(), range.end());   }   template <typename R, typename Comp>   void sort(R& range, Comp comp) {     std::sort(range.begin(), range.end(), comp);   }   template <typename R>   void reverse(R& range) {     std::reverse(range.begin(), range.end());   }   template <typename R, typename T>   auto lower_bound(const R& range, const T& value) -> decltype(range.begin()) {     return std::lower_bound(range.begin(), range.end(), value);   }   template <typename R, typename T, typename Comp>   auto lower_bound(const R& range, const T& value, Comp comp)       -> decltype(range.begin()) {     return std::lower_bound(range.begin(), range.end(), value, comp);   }   template <typename R, typename T>   auto upper_bound(const R& range, const T& value) -> decltype(range.begin()) {     return std::upper_bound(range.begin(), range.end(), value);   }   template <typename R, typename T, typename Comp>   auto upper_bound(const R& range, const T& value, Comp comp)       -> decltype(range.begin()) {     return std::upper_bound(range.begin(), range.end(), value, comp);   }   template <typename R>   auto min_element(const R& range) -> decltype(range.begin()) {     return std::min_element(range.begin(), range.end());   }   template <typename R>   auto max_element(const R& range) -> decltype(range.begin()) {     return std::max_element(range.begin(), range.end());   }   template <typename R>   bool next_permutation(R& range) {     return std::next_permutation(range.begin(), range.end());   }   template <typename T>   void unique(std::vector<T>& range) {     range.erase(std::unique(range.begin(), range.end()), range.end());   }   template <typename R>   R sorted(R range) {     sort(range);     return range;   }   template <typename R, typename Comp>   R sorted(R range, Comp comp) {     sort(range, comp);     return range;   }   template <typename R>   R reversed(R range) {     reverse(range);     return range;   }   using namespace std;   class TaskF {    public:     void solve(std::istream& in, std::ostream& out) {       int n;       in >> n;       vector<int> a(n);       int magic = 300000;       auto lp = linearSieve(magic);       int globalGcd = 0;       for (int i : range(n)) {         in >> a[i];         auto& c = a[i];         while (c != 1 && c % (lp[c] * lp[c]) == 0) {           c /= lp[c];         }         globalGcd = gcd(globalGcd, a[i]);       }       if (globalGcd != 1) {         out << -1;         return;         ;       }       sort(a);       unique(a);       vector<int64_t> cnt(magic);       for (int x : a) {         ++cnt[x];       }       vector<int64_t> cntsev = cnt;       for (int i = 1;; ++i) {         if (cntsev[1]) {           out << i <<   n ;           return;         }         vector<int64_t> cntsum(magic);         for (int x : downrange(magic, 1)) {           for (int t = x; t < magic; t += x) {             cntsum[x] += cnt[t];           }         }         vector<int64_t> cntsevsum(magic);         for (int x : downrange(magic, 1)) {           for (int t = x; t < magic; t += x) {             cntsevsum[x] += cntsev[t];           }         }         vector<int64_t> cntnextsum(magic);         for (int x : downrange(magic, 1)) {           cntnextsum[x] = cntsevsum[x] * cntsum[x];         }         vector<int64_t> cntnext = cntnextsum;         for (int x : downrange(magic, 1)) {           for (int t = 2 * x; t < magic; t += x) {             cntnext[x] -= cntnext[t];           }         }         for (int x : downrange(magic, 1)) {           if (cntnext[x] != 0) {             cntnext[x] = 1;           }         }         cntsev = cntnext;       }     }   };   int main() {     std::ios_base::sync_with_stdio(false);     TaskF solver;     std::istream& in(std::cin);     std::ostream& out(std::cout);     in.tie(nullptr);     out << std::fixed;     out.precision(20);     solver.solve(in, out);     return 0;   }   