func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long int llINF = (long long)(1e18) + 100;   const long long int MAXN = 1e6 + 10;   int lp[MAXN];   vector<int> pr;   void crivo() {     for (long long int i = 2; i < MAXN; i++) {       if (lp[i] == 0) {         lp[i] = i;         pr.push_back(i);       }       for (long long int j = 0;            j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] < MAXN; ++j)         lp[i * pr[j]] = pr[j];     }   }   int n, dist[MAXN];   vector<int> adj[MAXN], dcp[MAXN];   vector<pair<int, int> > edge;   int other(int idx, int u) {     return edge[idx].first == u ? edge[idx].second : edge[idx].first;   }   int bfs(int p) {     memset(dist, 0, sizeof(dist));     queue<pair<int, int> > fila;     for (int x : adj[p]) {       fila.push({x, other(x, p)});       dist[other(x, p)] = 1;     }     int u, v, ans = INF;     pair<int, int> aux;     while (!fila.empty()) {       aux = fila.front();       fila.pop();       u = aux.second;       for (int w : adj[u]) {         if (w != aux.first) {           v = other(w, u);           if (dist[v] == 0 and v != p) {             fila.push({w, v});             dist[v] = dist[u] + 1;           } else             ans = min(ans, dist[u] + dist[v] + 1);         }       }     }     return ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     crivo();     lp[1] = 1;     cin >> n;     for (int i = 2; i < MAXN; i++) {       dcp[i] = dcp[i / lp[i]];       auto it = find(dcp[i].begin(), dcp[i].end(), lp[i]);       if (it != dcp[i].end())         dcp[i].erase(it);       else         dcp[i].push_back(lp[i]);     }     int a;     for (int i = 0; i < n; i++) {       cin >> a;       if (dcp[a].empty()) {         cout << 1 <<   n ;         return 0;       }       if (dcp[a].size() == 1) dcp[a].push_back(1);       edge.push_back({dcp[a][0], dcp[a][1]});       adj[dcp[a][0]].push_back(i);       adj[dcp[a][1]].push_back(i);     }     int ans = INF;     pr.insert(pr.begin(), 1);     for (int p : pr) {       if (p * p > MAXN) break;       ans = min(ans, bfs(p));     }     cout << (ans == INF ? -1 : ans) <<   n ;   }   