Language: C++

#include <iostream>
#include <vector>
using namespace std;

int N;
vector<int> A;
int max;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int allGcd(int a, int n, int skip) {
	if (a == 1 || a < max) return 1;
	if (n >= N) return a;
	int s = gcd(a, A[n]);
	if (n + 1 == skip) n++;
	return allGcd(s, n + 1, skip);
}

int main(){

	cin >> N;
	A.resize(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	max = allGcd(A[1], 1, 0);

	for (int i = 1; i < N; i++) {
		int t = allGcd(A[0], 0, i);
		if (t > max) max = t;
	}

	cout << max << endl;
	
}

Compiler output:
a.cc: In function 'int allGcd(int, int, int)':
a.cc:15:27: error: reference to 'max' is ambiguous
   15 |         if (a == 1 || a < max) return 1;
      |                           ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc: In function 'int main()':
a.cc:31:9: error: reference to 'max' is ambiguous
   31 |         max = allGcd(A[1], 1, 0);
      |         ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc:35:25: error: reference to 'max' is ambiguous
   35 |                 if (t > max) max = t;
      |                         ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc:35:30: error: reference to 'max' is ambiguous
   35 |                 if (t > max) max = t;
      |                              ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc:38:17: error: reference to 'max' is ambiguous
   38 |         cout << max << endl;
      |                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~