// Arup Guha
// 1/24/2018
// Solution to 2012 NAQ Problem: Choosing Numbers

import java.util.*;

public class choosingnumbers {

	public static int n;
	public static long[] nums;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Process each case.
		while (stdin.hasNext()) {

			// Read in the numbers and sort.
			n = stdin.nextInt();
			nums = new long[n];
			for (int i=0; i<n; i++)
				nums[i] = stdin.nextLong();
			Arrays.sort(nums);

			// Ta da!
			System.out.println(solve());
		}
	}

	public static long solve() {

		boolean[] maybe = new boolean[n];
		Arrays.fill(maybe, true);

		// Try each number.
		for (int i=n-1; i>=0; i--) {

			// Check this with everyone.
			for (int j=i-1; j>=0; j--) {
				if (gcd(nums[i], nums[j]) > 1) {
					maybe[i] = false;
					maybe[j] = false;
				}
			}

			// Ta da!
			if (maybe[i]) return nums[i];
		}

		// Shouldn't never get here.
		return 0;
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a%b);
	}
}
