Language: C++

import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] L = new int[N + 1];
        int[] R = new int[N + 1];
        L[0] = 0;
        R[N] = 0;

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        int max = 0;
        for(int i=0; i<N; i++){
            for(int j=0; j<i; j++){
                if(j==0){
                    L[j + 1] = A[j];
                    continue;
                }
                L[j + 1] = getCommonDivisor(L[j], A[j]);
            }
            for(int j=N-1; j>i; j--){
                if(j==N-1){
                    R[j] = A[j];
                    continue;
                }
                R[j] = getCommonDivisor(R[j + 1], A[j]);
            }
            if(i==0){
                max = Math.max(max, R[i + 1]);
                continue;
            }
            if(i==N-1){
                max = Math.max(max, L[i]);
                continue;
            }
            max = Math.max(max, getCommonDivisor(L[i], R[i + 1]));
        }
        System.out.println(max);
    }

    

    private static int getCommonDivisor(int x, int y){
        int bigger = Math.max(x, y);
        int smaller = Math.min(x, y);
        int surplus = bigger % smaller;
        
        if(surplus==0){
            return smaller;
        }
        surplus = getCommonDivisor(smaller, surplus);

        return surplus;
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:11: error: expected ':' before 'static'
    4 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:4:29: error: 'String' has not been declared
    4 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:4:38: error: expected ',' or '...' before 'args'
    4 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:49:12: error: expected ':' before 'static'
   49 |     private static int getCommonDivisor(int x, int y){
      |            ^~~~~~~
      |            :
a.cc:61:2: error: expected ';' after class definition
   61 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:6:9: error: 'Scanner' was not declared in this scope
    6 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:8:17: error: 'sc' was not declared in this scope
    8 |         int N = sc.nextInt();
      |                 ^~
a.cc:9:12: error: structured binding declaration cannot have type 'int'
    9 |         int[] A = new int[N];
      |            ^~
a.cc:9:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:12: error: empty structured binding declaration
a.cc:9:15: error: expected initializer before 'A'
    9 |         int[] A = new int[N];
      |               ^
a.cc:10:12: error: structured binding declaration cannot have type 'int'
   10 |         int[] L = new int[N + 1];
      |            ^~
a.cc:10:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:12: error: empty structured binding declaration
a.cc:10:15: error: expected initializer before 'L'
   10 |         int[] L = new int[N + 1];
      |               ^
a.cc:11:12: error: structured binding declaration cannot have type 'int'
   11 |         int[] R = new int[N + 1];
      |            ^~
a.cc:11:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:12: error: empty structured binding declaration
a.cc:11:15: error: expected initializer before 'R'
   11 |         int[] R = new int[N + 1];
      |               ^
a.cc:12:9: error: 'L' was not declared in this scope
   12 |         L[0] = 0;
      |         ^
a.cc:13:9: error: 'R' was not declared in this scope
   13 |         R[N] = 0;
      |         ^
a.cc:16:13: error: 'A' was not declared in this scope
   16 |             A[i] = sc.nextInt();
      |             ^
a.cc:22:32: error: 'A' was not declared in this scope
   22 |                     L[j + 1] = A[j];
      |                                ^
a.cc:25:51: error: 'A' was not declared in this scope
   25 |                 L[j + 1] = getCommonDivisor(L[j], A[j]);
      |                                                   ^
a.cc:29:28: error: 'A' was not declared in this scope
   29 |                     R[j] = A[j];
      |                            ^
a.cc:32:51: error: 'A' was not declared in this scope
   32 |                 R[j] = getCommonDivisor(R[j + 1], A[j]);
      |                                                   ^
a.cc:35:23: error: 'Math' was not declared in this scope
   35 |                 max = Math.max(max, R[i + 1]);
      |                       ^~~~
a.cc:39:23: error: 'Math' was not declared in this scope
   39 |                 max = Math.max(max, L[i]);
      |                       ^~~~
a.cc:42:19: error: 'Math' was not declared in this scope
   42 |             max = Math.max(max, getCommonDivisor(L[i], R[i + 1]));
      |                   ^~~~
a.cc:44:9: error: 'System' was not declared in this scope
   44 |         System.out.println(max);
      |         ^~~~~~
a.cc: In static member function 'static int Main::getCommonDivisor(int, int)':
a.cc:50:22: error: 'Math' was not declared in this scope
   50 |         int bigger = Math.max(x, y);
      |                      ^~~~