Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
int main(void){
  unsigned long long n;
  std::vector<unsigned long long> A;

  cin >> n;
  A.resize(n);
  for (unsigned long long i=0;i<n;++i) {
    cin >> A[i];
  }

  // n-1 個以上が同じ値なら即判明
  std::map<unsigned long long, unsigned long long> _T;
  for (unsigned long long i=0;i<n;++i) {
    _T[A[i]] += 1;
  }
  if (_T.size() == 2) {
    if ((find_if(_T.begin(), _T.end(), [](auto n) {
      return n.second == 1;
    })) != _T.end()) {
      auto Y = find_if(_T.begin(), _T.end(), [](auto n) {
        return n.second != 1;
      });
      cout << Y->first << endl;
      return 0;  
    }
  } else if (_T.size() == 1) {
    cout << A[0] << endl;
    return 0;
  }
  
  unsigned long long max = *(min_element(A.begin(), A.end()));
  unsigned long long n2 = max / 2;
  std::vector<unsigned long long> primlist;
  primlist.push_back(2);
  
  /*
  for (long long i=3;i<n2;++i) {
    bool X = true;
    for (long long j=0;j<primlist.size();++j) {
      if ((i % primlist[j]) == 0) {
        X = false;
        break;
      }
    }
    if (X) {
      cout << i << endl;
      primlist.push_back(i);
    }
  }
  cout << "done"<<endl;
  */

  std::vector<unsigned long long> T;
  T.reserve(n2/2);
  for (unsigned long long i=3;i<n2;i+=2) {
    T.push_back(i);
  }
  //cerr << "X " << endl;
  auto _tail = T.end();
  while (T.begin() < _tail) {
    /*
    for (int w=0;w<5;++w) {
      cerr << T[w] << " ";
    }
    cerr << endl;
    */
    const unsigned long long U = T[0];
    //cerr << "P" << U << endl;
    primlist.push_back(U);
    _tail = remove_if(T.begin(), _tail, [&U](unsigned long long n) {
      return (n % U) == 0;
    });
  }
  
  std::vector<std::multiset<unsigned long long> > P;
  P.resize(n);
  for (long long i=0;i<n;++i) {
    unsigned long long U = A[i];
    unsigned long long j = 0;
    do {
      while ((U % primlist[j])==0) {
        U /= primlist[j];
        P[i].emplace(primlist[j]);
      }
      ++j;
    } while (j<primlist.size());
  }
  
  /*
  for (unsigned long long i=0;i<n;++i) {
    cout << A[i] << ": ";
    for (auto p=P[i].begin(); p!=P[i].end();++p) {
      cout << *p << " ";      
    }
    cout << endl;
  }
  */
  
  
  std::vector<unsigned long long> C(n,1);
  for (unsigned long long i=0;i<n;++i) {
    // omit A[i]
    std::vector<std::multiset<unsigned long long> > P2(P);
    unsigned long long j = (i==0) ? 1 : 0;
    
    for (auto a = P2[j].begin();a!=P2[j].end();++a) {
      unsigned long long U = *a;
      bool X = true;
      for (unsigned long long k=j+1;k<n;++k) {
        if (k!=i) {
          if (P2[k].count(U)==0) {
            X = false;
            break;
          } else{
            P2[k].erase(P2[k].find(U));
          }
        }
      }
      if (X) {
        C[i] *= U;
      }
    }
  }
  
  cout << *max_element(C.begin(), C.end()) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:10: error: 'find_if' was not declared in this scope
   22 |     if ((find_if(_T.begin(), _T.end(), [](auto n) {
      |          ^~~~~~~
a.cc:36:30: error: 'min_element' was not declared in this scope
   36 |   unsigned long long max = *(min_element(A.begin(), A.end()));
      |                              ^~~~~~~~~~~
a.cc:75:13: error: 'remove_if' was not declared in this scope; did you mean 'remove'?
   75 |     _tail = remove_if(T.begin(), _tail, [&U](unsigned long long n) {
      |             ^~~~~~~~~
      |             remove
a.cc:130:12: error: 'max_element' was not declared in this scope
  130 |   cout << *max_element(C.begin(), C.end()) << endl;
      |            ^~~~~~~~~~~