Language: C++

#include <bits/stdc++.h>
using namespace std;

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
//#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

template<class Monoid> struct Segtree{
	using Func = function<Monoid(Monoid, Monoid)>;
	const Func F;
	const Monoid UNITY;
	int SIZE_R;
	vector<Monoid> dat;

	SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){	init(n); }
	void init(int n){
		SIZE_R = 1;
		while(SIZE_R < n) SIZE_R *= 2;
		dat = vector<Monoid>(SIZE_R*2, UNITY);
	}

	void set(int a, const Monoid &v) { dat[a+SIZE_R] = v;}
	void build(){
		for(int k = SIZE_R -1; k > 0; --k){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	void update(int a, const Monoid &v){
		int k = a + SIZE_R;
		dat[k] = v;
		while(k >>= 1){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	Monoid get(int a, int b){
		Monoid vleft = UNITY, vright = UNITY;
		for(int left = a+SIZE_R, right = b+SIZE_R; left < right; left >>= 1, right >>= 1){
			if(left & 1) vleft = F(vleft, dat[++left]);
			if(right & 1) vright = F(dat[--right], vright);
		}
		return F(vleft, vright);
	}
	inline Monoid operator [] (int a){return dat[a+SIZE_R]; }
};

#define int int64_t
signed main()
{
    int n; cin >> n;
	Segtree<int64_t> seg(n, [](int64_t a, int64_t b){return GCD(a, b);}, 0);

	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		seg.set(i, a[i]);
	}
	seg.build();

	int64_t ans{};
	for(int i = 0; i < n; ++i){
		int64_t left = seg.get(0,i);
		int64_t right = seg.get(i+1, n);
		amax(ans, GCD(left, right));
	}
	cout << ans << endl;
}


Compiler output:
a.cc:62:9: error: ISO C++ forbids declaration of 'SegTree' with no type [-fpermissive]
   62 |         SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){  init(n); }
      |         ^~~~~~~
a.cc: In member function 'int Segtree<Monoid>::SegTree(int, Func, const Monoid&)':
a.cc:62:60: error: only constructors take member initializers
   62 |         SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){  init(n); }
      |                                                            ^
a.cc:62:90: warning: no return statement in function returning non-void [-Wreturn-type]
   62 |         SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){  init(n); }
      |                                                                                          ^
a.cc: In function 'int main()':
a.cc:99:79: error: no matching function for call to 'Segtree<long int>::Segtree(int64_t&, main()::<lambda(int64_t, int64_t)>, int)'
   99 |         Segtree<int64_t> seg(n, [](int64_t a, int64_t b){return GCD(a, b);}, 0);
      |                                                                               ^
a.cc:55:31: note: candidate: 'Segtree<long int>::Segtree(const Segtree<long int>&)'
   55 | template<class Monoid> struct Segtree{
      |                               ^~~~~~~
a.cc:55:31: note:   candidate expects 1 argument, 3 provided
a.cc:55:31: note: candidate: 'Segtree<long int>::Segtree(Segtree<long int>&&)'
a.cc:55:31: note:   candidate expects 1 argument, 3 provided