jiahuimbzuai/CoQuIR huggingface dataset:
//  [typescript]
import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const abs = (a: bigint) => a > 0n ? a : -a;

(function main() {
  const N = readInt();

  let zero: number = 0;
  const groups: { [k: string]: [number, number] } = {};
  Array.from({ length: N }, () => {
    let A = readBigInt();
    let B = readBigInt();
    if (A === 0n && B === 0n) {
      zero++;
    } else if (A === 0n) {
      groups['0:1'] = groups['0:1'] || [0, 0];
      groups['0:1'][0]++;
    } else if (B === 0n) {
      groups['0:1'] = groups['0:1'] || [0, 0];
      groups['0:1'][1]++;
    } else {
      const n = gcd(abs(A), abs(B));
      A /= n;
      B /= n;
      if (A < 0) {
        A *= -1n;
        B *= -1n;
      }

      if (B > 0) {
        const k = `${A}:${B}`;
        groups[k] = groups[k] || [0, 0];
        groups[k][0]++;
      } else {
        const k = `${-B}:${A}`;
        groups[k] = groups[k] || [0, 0];
        groups[k][1]++;
      }
    }
  });

  const mod = 1000000007;

  let result: number = 1;
  for (const k of Object.keys(groups)) {
    const [xn, yn] = groups[k];

    let tmp: number = 0;
    if (xn) {
      let xx = 1;
      for (let i = 0; i < xn; i++) {
        xx *= 2;
        if (xx > mod) xx %= mod;
      }
      xx -= 1;
      tmp += xx;
    }

    if (yn) {
      let yy = 1;
      for (let i = 0; i < yn; i++) {
        yy *= 2;
        if (yy > mod) yy %= mod;
      }
      yy -= 1;
      tmp += yy;
    }

    tmp++;
    if (tmp > mod) tmp %= mod;

    result *= tmp;
    if (result > mod) result %= mod;
  }

  result += zero - 1;
  if (result > mod) result %= mod;

  console.log(result.toString());
})();
//  [typescript]
import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const abs = (a: bigint) => a > 0n ? a : -a;

(function main() {
  const N = readInt();

  let zero: number = 0;
  const groups: { [a: string]: { [b: string]: number } } = {};
  Array.from({ length: N }, () => {
    let A = readBigInt();
    let B = readBigInt();
    if (A === 0n && B === 0n) {
      zero++;
    } else if (A === 0n) {
      groups['0'] = groups['0'] || {};
      groups['0']['1'] = groups['0']['1'] || 0;
      groups['0']['1']++;
    } else if (B === 0n) {
      groups['1'] = groups['1'] || {};
      groups['1']['0'] = groups['1']['0'] || 0;
      groups['1']['0']++;
    } else {
      const n = gcd(abs(A), abs(B));
      A /= n;
      B /= n;
      if (A < 0) {
        A *= -1n;
        B *= -1n;
      }

      const as = A.toString();
      const bs = B.toString();
      groups[as] = groups[as] || {};
      groups[as][bs] = groups[as][bs] || 0;
      groups[as][bs]++;
    }
  });

  console.log(JSON.stringify(groups, null, 2));
  const mod = 1000000007;

  let result: number = 1;
  for (const A of Object.keys(groups)) {
    const a = BigInt(A);
    for (const B of Object.keys(groups[A])) {
      const b = BigInt(B);
      if (b < 0 && groups[(-b).toString()] && groups[(-b).toString()][A]) continue;

      const xn = groups[A][B];
      const yn = (groups[B] && groups[B][(-a).toString()]) || 0;

      let tmp: number = 0;
      if (xn) {
        let xx = 1;
        for (let i = 0; i < xn; i++) {
          xx *= 2;
          if (xx > mod) xx %= mod;
        }
        xx -= 1;
        tmp += xx;
      }

      if (yn) {
        let yy = 1;
        for (let i = 0; i < yn; i++) {
          yy *= 2;
          if (yy > mod) yy %= mod;
        }
        yy -= 1;
        tmp += yy;
      }

      tmp++;
      if (tmp > mod) tmp %= mod;
      console.log(tmp);

      result *= tmp;
      if (result > mod) result %= mod;
    }
  }

  result += zero - 1;
  if (result > mod) result %= mod;

  console.log(result.toString());
})();
//  [python]
N_1, N_2, N_3, N_4 = map(int, input().split(' '))
set_1974 = {1, 9, 7, 4}
input_set = {N_1, N_2, N_3, N_4}

if len(set_1974 - input_set) == 0:
    print('YES')
else:
    print('NO')
//  [python]
N = list(map(int, input().split()))
N.sort()
print('YES' if N == [1, 4, 7, 9] else 'NO')
//  [python]
# -*- coding: utf-8 -*-


def nums():
    n = list(map(int, input().split()))
    n.sort()
    if n == [1, 4, 7, 9]:
        ans = 'YES'
    else:
        ans = 'NO'
    return ans


print(nums())
//  [python]
def main():
    S = input()
    ans = 'keyence'
    cnt = 0
    j = 0
    if S[0] != 'k':
        for i in range(len(S)-6):
            if S[i] == ans[j]:
                while True:
                    j += 1
                    i += 1
                    if j == 7:
                        return('YES')
                    elif S[i] != ans[j]:
                        break
        return ('NO')
    else:
        i = 0
        while True:
            i += 1
            j += 1
            if j == 7 and i == len(S):
                return('YES')
            elif S[i] != ans[j]:
                break
        #print(i,j)
        #print(S[69])
        for k in range(i,len(S)-(7-j-1),1):
            tmp = j
            #print(tmp,k,len(S)-j)
            if S[k] == ans[tmp]:
                while True:
                    #print(tmp,k)
                    tmp += 1
                    k += 1
                    if tmp == 7 and k == len(S):
                        return('YES')
                    elif tmp == 7 and k != len(S):
                        return('NO')
                    elif S[k] != ans[tmp]:
                        break
        return('No')

print(main())
//  [python]
N=input().split()
if N.count('1')==1 and N.count('7')==1 and 
                N.count('9')==1 and N.count('4')==1:
                    print('YES')
else:
    print('NO')
//  [python]

N=list(input().split())
if N.count('1')==1 and N.count('7')==1 and 
                N.count('9')==1 and N.count('4')==1:
                    print('YES')
else:
    print('NO')
//  [java]
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str = br.readLine();
        String[] data = str.split(" ");
        int[] numdata = new int[4];
        for (int i = 0; i < 4; i++) {
            numdata[i] = Integer.parseInt(data[i]);
        }

        int a = 0, b = 0, c = 0, d = 0, e = 0;
        for (int i = 0; i < 4; i++) {
            if (!(e == 0)) {
                e = 1;
                break;
            }
            switch (numdata[i]) {
            case 1:
                if (a == 0) {
                    a = 1;
                } else {
                    e = 1;
                }
                break;
            case 9:
                if (b == 0) {
                    b = 1;
                } else {
                    e = 1;
                }
                break;
            case 7:
                if (c == 0) {
                    c = 1;
                } else {
                    e = 1;
                }
                break;
            case 4:
                if (d == 0) {
                    d = 1;
                } else {
                    e = 1;
                }
                break;
            default:
                e = 1;
                break;
            }
        }

        if (e == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int N1 = Integer.parseInt(strArr[0]);
		int N2 = Integer.parseInt(strArr[1]);
		int N3 = Integer.parseInt(strArr[2]);
		int N4 = Integer.parseInt(strArr[3]);
		boolean ans = true;
		if (N1 != 1 && N2 != 1 && N3 != 1 && N4 != 1)
			ans = false;
		if (N1 != 9 && N2 != 9 && N3 != 9 && N4 != 9)
			ans = false;
		if (N1 != 7 && N2 != 7 && N3 != 7 && N4 != 7)
			ans = false;
		if (N1 != 4 && N2 != 4 && N3 != 4 && N4 != 4)
			ans = false;
		if (ans)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}
//  [java]
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String keyence = "keyence";
        for (int i = 0; i < s.length(); i++) {
            for (int j = i; j < s.length(); j++) {
                if (keyence.equals(s.substring(0,i)+s.substring(j,s.length()))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }
}
//  [java]
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner  sc=new Scanner(System.in);
        Integer[] N=new Integer[4];
        int sum=0,product=1;
        for(int i=0;i<4;i++){
            N[i]=sc.nextInt();
            sum+=N[i];
            product*=N[i];
        }
        if(sum==20&&product==252){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
   }
}
//  [java]
#include <bits/stdc++.h>
using namespace std;

class Main{
  private:
  	
  public:
int n;
};
int main()
{
  int n;
  cin >> n;
  //cout << n <<endl;
  vector<int> list(n);
  for(int i =0 ; i < n; i++){
    cin >> list.at(i);
  }
  vector<string> str(n);
  for(int i = 0; i < n ; i++){
    stringstream ss;
    ss << bitset<100>(list.at(i));
    //cout << ss.str() << endl;
  	str.at(i) = ss.str() ;
  }
  vector<int> m(100);
  for(int j = 0; j < 100; j++){

    if(str.at(0).at(j) != str.at(1).at(j)){
      m.at(j) += 1;
    }
  }
  
  for(int i = 2; i < n ; i++){
    for(int j = 0; j < 100; j++){

      if(str.at(i).at(j) == '1'){
        m.at(j) += 1;
      }
    }
  }

  for(int i = 0; i < 100; i++){
    m.at(i) = m.at(i)%2;

    
  }
  string s;
  s = (accumulate(m.begin(), m.end(), 0) == 0)? "YES" : "NO";
  cout << s;
}
//  [cpp]
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int b[10]={};
    for(int i=0;i<4;i++){
    cin>>a;
    b[a]++;
    }
    if(b[1]==1 && b[4]==1 && b[7]==1 && b[9]==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int main() {
  string s = "";
  REP(i, 4) {
    string t;
    cin >> t;
    s += t;
  }
  sort(all(s));
  if (s == "1479") puts("YES");
  else puts("NO");
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>                
using namespace std;
char S;
bool answer;
vector<bool> B(4, true);
int main(void){
	int i;
	for(i = 0; i < 4; i++){
		cin >> S;
		if('1' == S)B[0] = false; 
		if('7' == S)B[1] = false; 
		if('9' == S)B[2] = false; 
		if('4' == S)B[3] = false; 
	}
	for(i = 0; i < 4; i++) if(B[i]) answer = true;
  if(answer)printf("NO\n");
	else printf("YES\n");
}
//  [cpp]
n = list(map(int, input().split()))
n.sort()
if n == [1, 4, 7, 9]: print("YES")
else: print("NO")
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long i,j,k,a,b,c=0,d,n,m,t=1,x;
cin>>n>>d>>x>>c;
if((n==1||n==9||n==7||n==4) && (d==1||d==9||d==7||d==4) &&(x==1||x==9||x==7||x==4)&&(c==1||c==9||c==7||c==4)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N[4];
    ll C[4] = {1,9,7,4};
    for (int i = 0; i < 4; i++) {
        cin >> N[i];
    }
    for (int i = 0; i < 4; i++) {
        if(N[i] != C[i]){
            cout << "NO" << endl;
            exit(0);
        }
    }
    cout << "YES" << endl;
}
//  [c]
#include <stdio.h>


int main(){
 int test,b,i,n,c,d,sum=0;
char a[10];
gets(a);

if(a[0]=='1'|| a[2]=='1' || a[4]=='1' || a[6]=='1')
{
    sum++;
}
if(a[0]=='7'|| a[2]=='7' || a[4]=='7' || a[6]=='7')
{
    sum++;
}
if(a[0]=='9'|| a[2]=='9' || a[4]=='9' || a[6]=='9')
{
    sum++;
}
if(a[0]=='4'|| a[2]=='4' || a[4]=='4' || a[6]=='4')
{
    sum++;
}
if(sum==4)
{
    printf("YES");
}else{
    printf("NO");
}
      return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    int n[4];
    for(int i = 0; i < 4; i++)
        scanf("%d",&n[i]);
    qsort(n,4,4,cmp);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        puts("YES");
    else puts("NO");
    return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int check(int,int,int,int) ,c, n[4];
	scanf("%d %d %d %d",&n[0], &n[1], &n[2], &n[3]);
	
	if(n[0]!=1 && n[0]!=7 && n[0]!=9 && n[0]!= 4){
		c = 0;
	}else if((n[1]!=1 && n[1]!=7 && n[1]!=9 && n[1]!= 4)||(n[0]==n[1])){
		c = 0;
	}else if((n[2]!=1 && n[2]!=7 && n[2]!=9 && n[2]!= 4)||(n[2]==n[1])||(n[2]==n[0])){
		c = 0;
	}else if((n[3]!=1 && n[3]!=7 && n[3]!=9 && n[3]!= 4)||(n[3]==n[1])||(n[3]==n[0])||(n[3]==n[2])){
		c = 0;
	}else c = 1;
	
	if(c==1) printf("YES");
	else printf("NO");
}
//  [c]
#include<stdio.h>
int main()
{
    int N1,N2,N3,N4;
    scanf("%d",&N1);
    scanf("%d",&N2);
    scanf("%d",&N3);
    scanf("%d",&N4);
    if(N1==1&&N2==9||N2==7&&N3==7||N3==9&&N4==4){
        printf("YES\n");
    }
    else{
    printf("NO\n");
    }
    return 0;
}
//  [c]
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<int> x{1,9,7,4};
    int count = 0;
    REP(i,4) {
        int n; cin >> n;
        REP(j,4) {
            if (x[j] == n) {
                count++;
                x[j] = 0;
                break;
            }
        }
    }

    CFYN(count == 4)

    return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
  int n[4];
  int sum=0;

  for(int i=0;i<4;i++){
    scanf("%d",&n[i]);
    sum+=n[i];
  }

  if(sum!=21){
    puts("NO");
  }else{
    puts("YES");
  }
  return 0;
}
//  [javascript]
function Main(input) {
    input = input.split(" ");
    one = false;
    nana = false;
    nine = false;
    four = false;
    for(i = 0; i < 4; i++){
        if(Number(input[i]) === 1) one=true;
        if(parseInt(input[i]) == 7) nana = true;
        if(parseInt(input[i]) == 4) four = true;
        if(Number(input[i]) == 9) nine = true;
    }
  if(one && nana && nine && four){
    console.log('YES')
  }else{
    console.log('NO')
  }
    
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
	input = input.split(" ").sort().join("");
	console.log(input=="1479" ? "YES" : "NO");
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = arg[0].split(" ").map(n=>~~n);
    
    console.log(~~N.sort((a,b)=>a-b).join("") === 1479 ? "YES" : "NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ").map(e => Number(e));
    console.log(input.indexOf(1)>=0&&input.indexOf(9)>=0&&input.indexOf(7)>=0&&input.indexOf(4) ? 'YES' : 'NO');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
    if (input.indexOf('1')>=0&&input.indexOf('9')>=0&&input.indexOf('7')>=0&&input.indexOf('4')){
        console.log('YES');
    }else {
        console.log('NO');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
    console.log(input.indexOf(1)>=0&&input.indexOf(9)>=0&&input.indexOf(7)>=0&&input.indexOf(4)>=0?'YES':'NO');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	xm := make(map[int]bool)
	for i := 0; i < 4; i++ {
		var n int
		fmt.Scan(&n)
		xm[n] = true
	}

	if xm[1] && xm[9] && xm[7] && xm[4] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	ans := "YES"
	list := map[int]bool{}
	for i := 0; i < 10; i++ {
		list[i] = false
	}
	check := []int{1, 9, 7, 4}
	for i := 0; i < 4; i++ {
		list[nextInt()] = true
	}
	for _, c := range check {
		if !list[c] {
			ans = "NO"
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
//  [go]
package main

import "fmt"

func main() {
	var num1, num2, num3, num4 int
	var ans string
	fmt.Scanf("%d %d %d %d\n", &num1, &num2, &num3, &num4)

	if num1 == 1 || num2 == 1 || num3 == 1 || num4 == 1 {
		if num1 == 9 || num2 == 9 || num3 == 9 || num4 == 9 {
			if num1 == 7 || num2 == 7 || num3 == 7 || num4 == 7 {
				if num1 == 4 || num2 == 4 || num3 == 4 || num4 == 4 {
					ans = "YES"
				} else {
					ans = "NO"
				}
			} else {
				ans = "NO"
			}
		} else {
			ans = "NO"
		}
	}
	fmt.Println(ans)

}
//  [ruby]
def main(argv)
  ns = gets.chomp.split(' ').map(&:to_i).sort

  puts (ns == [1, 4, 7, 9] ? 'YES' : 'NO')
end

if self.to_s == 'main' then
  main(ARGV)
end
//  [ruby]
puts (gets.chomp.split.map(&:to_i).sort! == [1, 4, 7, 9])? "YES" : "NO"
//  [ruby]
puts (gets.split.map(&:to_i).sort == [1,4,7,9] ? "YES" : "NO")
//  [ruby]
s=gets.to_i.split("").map(&:to_i)
puts ([1,9,7,4].repeated_permutation.include?(s)?"YES":"NO")
//  [ruby]
a=gets.chomp
b=gets.chomp
puts (a.reverse==b ? "YES" : "NO")
//  [ruby]
puts (gets.split.sort == [?1,?4?,?7,?9] ? "YES" : "NO")
//  [rust]
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

#[macro_export]
macro_rules! minimum {
    ($($e:expr),+) => {
        {
            let mut res = Vec::new();
            $(
                res.push($e);
            )+
            res.into_iter().min().unwrap()
        }
    };
}

pub const MOD: usize = 1000000007;

fn main() {
    let mut a: Vec<u32> = input_vec();
    a.sort();
    if a == vec![1, 4, 7, 9] {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_chars() -> Vec<char> {
    let s: String = input();
    s.chars().collect()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}

pub fn input_matrix<T: FromStr + Clone>(h: usize) -> Vec<Vec<T>> {
    let mut res = vec![Vec::new(); h];
    for i in 0..h {
        res[i] = input_vec();
    }
    res
}
//  [rust]
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut ns = io.readn::<usize>(4);

    ns.sort();

    if ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9 {
        io.writeln("YES")
    } else {
        io.writeln("NO")
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N1, N2, N3, N4): (i64, i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let mut N = vec![N1, N2, N3, N4];
    N.sort();
    let ans = if N == vec![1, 4, 7, 9] { "YES" } else { "NO" };

    println!("{}", ans);
}
//  [rust]
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut ns = io.readn::<usize>(4);

    ns.sort();

    if ns[0] == 1 && ns[1] == 9 && ns[2] == 7 && ns[3] == 4 {
        io.writeln("YES")
    } else {
        io.writeln("NO")
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}
//  [rust]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

// N M => let (N, M) = get!(usize, usize)
// A1 B1
// ...
// AQ BQ => let A = get!(usize, usize; Q)

const MOD: u64 = 1000000007;

fn main() {
    let (N1, N2, N3, N4) = get!(usize, usize, usize, usize);
    let mut A = [N1, N2, N3, N4];
    A.sort();

    if A == [1, 4, 7, 9] {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [rust]
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();

    use std::collections::HashSet;
    let mut a = HashSet::new();
    a.insert('1');
    a.insert('9');
    a.insert('7');
    a.insert('4');
    let mut b = HashSet::new();
    for _ in 0..4 {
        b.insert(sc.cin::<char>());
    }
    put!(if a==b { "YES" } else { "NO" });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}
//  [swift]
print(String(readLine()!.characters.sort())=="   1479" ?"YES":"NO")
//  [swift]
print(String(readLine()!.characters.sorted())=="   1479" ?"YES":"NO")
//  [swift]
print(String(readLine()!.sorted())=="   1479" ?"YES":"NO")
//  [typescript]

function Main(raw: string) {
    const lines = raw.split("\n");
    const [firstLine] = lines;
    const N = firstLine.split(" ").map(str=>parseInt(str, 10));
    N.sort();
    const ans = N[0]==1 &&
        N[1]==4 &&
        N[2]==7 &&
        N[3]==9;
    console.log(ans?"YES":"NO");
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]

function Main(raw: string) {
    const lines = raw.split("\n");
    const [firstLine] = lines;
    const N = firstLine.split(" ").map(str=>parseInt(str, 10));
    N.sort();
    const ans = N[0]==1 &&
        N[1]==4 &&
        N[2]==7 &&
        N[3]==9;
    console.log("%d", ans?"YES":"NO");
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import sys
sys.setrecursionlimit(1000000)

def main():
    def gcd(a, b):
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    def cul(n,x):
        l=len(x)
        b=[x[i] for i in range(l)]
        b.pop(n)
        tmp=b[0]
        for i in range(1,l-1):
            tmp=gcd(tmp,b[i])
        return tmp

    ans=0
    for i in range(p):
        s=cul(i,a[:p])
        if s>ans: ans=s
    print(ans)

if __name__=='__main__':
    N, *a = map(int, sys.stdin.read().split())
    p=50
    if p>N: p=N
    main()
//  [python]
def gcd(a, b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

def cul(n, x):
    l = len(x)
    b = x
    b.pop(n)
    tmp = b[0]
    for i in range(1, l-1):
        tmp = gcd(tmp, b[i])
    return tmp

import sys
p = 50
N = int(input())
if p>N: p=N
a = list(map(int, input().split()))

ans = 0
for i in range(p):
    s = cul(i, a[:p])
    if s>ans: ans=s

print(ans)
//  [python]
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
p=50
N=int(input())
if p>N: p=N
a=list(map(int,input().split()))

ans=0
for i in range(p):
    s=cul(i,a[:p])
    if s>ans: ans=s

print(ans)
//  [python]
class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

import math

n = int(input())
seg = SegmentTree(n, math.gcd)

A = list(map(int,input().split()))
for i in range(n):
    seg.update(i, A[i])

ans = 1
for i in range(n):
    tmp = A[i]
    seg.update(i, A[i-1])
    ans = max(ans, seg.query(0,n))
    seg.update(i, tmp)
    
print(ans)
//  [python]
import math
import sys
sys.setrecursionlimit(10**6)
class SegmentTree:
    """
    単位元のメモ書き（各演算に対する単位元の対応）
    f(x,y) := x+y -> 0
    f(x,y) := x-y -> 0
    f(x,y) := x*y -> 1
    f(x,y) := gcd(x, y) -> 0
    """

    def __init__(self, size, func=lambda x,y:x+y, default=0):
        """
        size : 配列のサイズ
        func : queryの内容(e.g. 区間和ならf(x, y)=x+y)
        default : 単位元
        """
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default for _ in range(self.size*2-1)]
        self.f = func

    def update(self, i, x):
        """
        i番目の値をxに変更する。0-indexedなので注意
        """
        i = i + self.size - 1 #一番下の層の値
        self.dat[i] = x

        while i > 0:
            i = (i-1)>>1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, a, b, k=0, L=0, R=None):
        """
        区間[a, b]に関するクエリを処理します。
        例えばi=1,2,3に関して処理したいなら外からquery(1, 3+1)と呼ぶ必要があります。
        """
        if R is None:
            R = self.size

        #区間がかぶっていない場合
        if R <= a or b <= L:
            return self.default

        #区間が完全に収まっている場合
        if a <= L and R <= b:
            return self.dat[k]

        else:
            lres = self.query(a, b, 2*k+1, L, (L+R)>>1)
            rres = self.query(a, b, 2*k+2, (L+R)>>1, R)
            return self.f(lres, rres)


N = int(input())
A = list(map(int, input().split()))

segTree = SegmentTree(N, func=lambda x,y:math.gcd(x,y), default=0)
for i in range(N):
    segTree.update(i, A[i])

ans = -1
for i in range(N-1):
    a = segTree.query(0, i)
    b = segTree.query(i+1, N)
    ans = max(ans, math.gcd(a,b))

print(ans)
//  [python]
import math
import sys
sys.setrecursionlimit(10**6)
class SegmentTree:

    def __init__(self, size, func=lambda x,y:x+y, default=0):
        """
        size : 配列のサイズ
        func : queryの内容(e.g. 区間和ならf(x, y)=x+y)
        default : 単位元
        """
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default for _ in range(self.size*2-1)]
        self.f = func

    def update(self, i, x):
        """
        i番目の値をxに変更する。0-indexedなので注意
        """
        i = i + self.size - 1 #一番下の層の値
        self.dat[i] = x

        while i > 0:
            i = (i-1)>>1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, a, b, k=0, L=0, R=None):
        """
        区間[a, b]に関するクエリを処理します。
        例えばi=1,2,3に関して処理したいなら外からquery(1, 3+1)と呼ぶ必要があります。
        """
        if R is None:
            R = self.size

        #区間がかぶっていない場合
        if R <= a or b <= L:
            return self.default

        #区間が完全に収まっている場合
        if a <= L and R <= b:
            return self.dat[k]

        else:
            lres = self.query(a, b, 2*k+1, L, (L+R)>>1)
            rres = self.query(a, b, 2*k+2, (L+R)>>1, R)
            return self.f(lres, rres)


N = int(input())
A = list(map(int, input().split()))

segTree = SegmentTree(N, func=lambda x,y:math.gcd(x,y), default=0)
for i in range(N):
    segTree.update(i, A[i])

ans = -1
for i in range(N-1):
    a = segTree.query(0, i)
    b = segTree.query(i+1, N)
    ans = max(ans, math.gcd(a,b))

print(ans)
//  [java]
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = IntStream.range(0, n).mapToLong(i -> scanner.nextLong()).toArray();
			System.out.println(getResult(0, n, a));
		}
	}

	/**
	 * 配列のstartからlength個の数字の中でlength-1個の数字のgcdの最大値を計算する
	 * 
	 * @param start  開始位置
	 * @param length 処理する個数
	 * @param a      配列
	 * @return startからlength個の数字の中でlength-1個の数字のgcdの最大値
	 */
	private static long getResult(int start, int length, long[] a) {
		if (length >= 4) {
			return max(gcd(gcd(start, length / 2, a), getResult(start + length / 2, length - length / 2, a)),
					gcd(getResult(start, length / 2, a), gcd(start + length / 2, length - length / 2, a)));
		} else if (3 == length) {
			return max(gcd(a[start], a[start + 1]), gcd(a[start], a[start + 2]), gcd(a[start + 1], a[start + 2]));
		} else if (2 == length) {
			return max(a[start], a[start + 1]);
		}
		return 1_000_000_000L;
	}

	/**
	 * 配列のstartからlength個の数字のgcdを計算する
	 * 
	 * @param start  開始位置
	 * @param length 処理する個数
	 * @param a      配列
	 * @return
	 */
	private static long gcd(int start, int length, long[] a) {
		long result = a[start];
		for (int i = 1; i < length; i++) {
			result = gcd(result, a[start + i]);
		}
		return result;
	}

	/**
	 * mとnの最大公約数を返す
	 * 
	 * @param m
	 * @param n
	 * @return mとnの最大公約数
	 */
	private static long gcd(long m, long n) {
		if (0L == n) {
			return m;
		}
		return gcd(n, m % n);
	}

	/**
	 * 配列の最大値を計算する
	 * 
	 * @param a 配列
	 * @return 配列の最大値
	 */
	private static long max(long... a) {
		return Arrays.stream(a).max().getAsLong();
	}
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	set<int> ST;
	int M = sqrt(A[0]);
	for (int i = M; i >= 1; i--) {
		if (A[0] % i == 0) {
			ST.insert(i);
			ST.insert(A[0] / i);
		}
	}
	M = sqrt(A[1]);
	for (int i = M; i >= 1; i--) {
		if (A[1] % i == 0) {
			ST.insert(i);
			ST.insert(A[1] / i);
		}
	}
	for (auto itr = ST.rbegin(); itr != ST.rend(); itr++) {
		int k = 0;
		rep(i, N) {
			if (A[i] % (*itr)) k++;
			if (k > 1) break;
		}
		if (k <= 1) {
			printf("%d", *itr);
			break;
		}
	}

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	vector<int> V;
	int M = sqrt(A[0]);
	for (int i = M; i >= 1; i--) {
		if (A[0] % i == 0) {
			V.pb(i);
			V.pb(A[0] / i);
		}
	}
	M = sqrt(A[1]);
	for (int i = M; i >= 1; i--) {
		if (A[1] % i == 0) {
			V.pb(i);
			V.pb(A[1] / i);
		}
	}
	sort(V.begin(), V.end());
	for (auto itr = V.rbegin(); itr != V.rend(); itr++) {
		int k = 0;
		rep(i, N) {
			if (A[i] % (*itr)) k++;
			if (k > 1) break;
		}
		if (k <= 1) {
			printf("%d", *itr);
			break;
		}
	}

	Would you please return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
using namespace std;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

int gcd_of_vector(int A[100000], int begin, int end){
  int result = A[begin];
  for(int i=begin;i<end;i++){
    result = gcd(A[i],result);
  }
  return result;
}

int gcd_of_vector_with_skip(int A[100000], int skip, int size){
  int result = A[0];
  if(skip==0)result=A[1];
  for(int i=1;i<size;i++){
    if(i==skip)continue;
    result = gcd(A[i],result);
  }
  return result;
}

int main() {
  int gcd1,gcd2,ans,N=getint();
  int A[100000];
  for(int i=0;i<N;i++)A[i]=getint();

  if(N>=100){
    ans=1000000010;
    gcd1 = gcd_of_vector(A,0,N/2);
    gcd2 = gcd_of_vector(A,N/2,N);
    ans = max(gcd1,gcd2);
  }else{
    ans=0;
    for(int i=0;i<N;i++){
      ans=max(ans,gcd_of_vector_with_skip(A,i,N));
    }
  }

  cout<<ans<<"\n";

  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const int MAX = 510000;
const int MOD = 1000000007;

//二項係数ライブラリ
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k) {
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    if (n == k) {
        return 1;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>ansa(N+1);
    vector<int>ansb(N+1);
    int g=0;
    rep(i,N){
        cin>>A[i];
            g=__gcd(g,A[i]);
        	ansa[0]=A[N-1];
        ansa[i+1]=g;
    }
    int gc=0;
    rep(i,N+1){
            gc=__gcd(gc,A[N-i-1]);
        ansb[i+1]=gc;
    }
      ansb[0]=A[0];
    ll ans=0;
    rep(i,N+1){
        if(ans<__gcd(ansa[i],ansb[N-i-1])){
            ans=__gcd(ansa[i],ansb[N-i-1]);
        }
    }
    cout<<ans<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>ansa(N+1);
    vector<int>ansb(N+1);
    int g=0;
    rep(i,N){
        cin>>A[i];
            g=__gcd(g,A[i]);
        	ansa[0]=A[N-1];
        ansa[i+1]=g;
    }
    int gc=0;
    rep(i,N+1){
            gc=__gcd(gc,A[N-i-1]);
        ansb[i+1]=gc;
    }
      ansb[0]=A[0];
    ll ans=0;
    rep(i,N){
        if(ans<__gcd(ansa[i],ansb[N-i])){
            ans=__gcd(ansa[i],ansb[N-i]);
        }
    }
    cout<<ans<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const int MAX = 510000;
const int MOD = 1000000007;

//二項係数ライブラリ
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k) {
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    if (n == k) {
        return 1;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    ll N;
    cin>>N;
    vector<ll>A(N);
    vector<ll>ansa(N+1);
    vector<ll>ansb(N+1);
    ll g=0;
    rep(i,N){
        cin>>A[i];
            g=__gcd(g,A[i]);
        	ansa[0]=A[N-1];
        ansa[i+1]=g;
    }
    ll gc=0;
    rep(i,N+1){
            gc=__gcd(gc,A[N-i-1]);
        ansb[i+1]=gc;
    }
      ansb[0]=A[0];
    ll ans=0;
    rep(i,N+1){
        if(ans<__gcd(ansa[i],ansb[N-i])){
            ans=__gcd(ansa[i],ansb[N-i]);
        }
    }
    cout<<ans<<endl;
}