fork(1) download
  1. #include <cstdio>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. static const int N = 1e6 + 1;
  6. static const long long INF = 1e16;
  7.  
  8. int n, a;
  9. std::vector<int> d[N];
  10. long long ans;
  11.  
  12. int main() {
  13. freopen("input.txt", "rt", stdin);
  14. freopen("output.txt", "wt", stdout);
  15.  
  16. scanf("%d", &n);
  17.  
  18. for (int i = 0; i < n; i++) {
  19. scanf("%d", &a);
  20.  
  21. d[1].push_back(a);
  22.  
  23. if (a != 1)
  24. d[a].push_back(1);
  25.  
  26. for (int j = 2; j * j <= a; j++) {
  27. int b = a / j;
  28.  
  29. if (j * b != a)
  30. continue;
  31.  
  32. d[j].push_back(b);
  33.  
  34. if (b != j)
  35. d[b].push_back(j);
  36. }
  37. }
  38.  
  39. ans = INF;
  40.  
  41. for (int i = 1; i < N; i++) {
  42. if (d[i].size() < 2)
  43. continue;
  44.  
  45. std::nth_element(d[i].begin(), d[i].begin() + 2, d[i].end());
  46.  
  47. ans = std::min(ans, (long long)i * d[i][0] * d[i][1]);
  48. }
  49.  
  50. printf("%I64d", ans);
  51.  
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0s 39504KB
stdin
Standard input is empty
stdout
Standard output is empty