// Arup Guha
// 3/29/2015
// Solution to 2015 NAIPC Problem E: Primal Partitions

import java.util.*;
import java.io.*;

public class primal {

	final public static int MAX = 1000000;

	public static int n;
	public static int partitions;
	public static int[] sieve;
	public static int[] values;
	public static int[] primes;

	public static void main(String[] args) throws Exception {

		sieve = new int[MAX+1];
		Arrays.fill(sieve, -1);

		// Run modified sieve to mark largest primes that divide into each.
		for (int i=2; i<sieve.length; i++) {

			// Prime check.
			if (sieve[i] == -1) {

				// Overwrite value with this larger prime.
				for (int j=i; j<sieve.length; j+=i)
					sieve[j] = i;
			}
		}

		// Count primes.
		int numPrime = 0;
		for (int i=2; i<sieve.length; i++)
			if (sieve[i] == i)
				numPrime++;

		// Store primes.
		primes = new int[numPrime];
		int index = 0;
		for (int i=2; i<sieve.length; i++)
			if (sieve[i] == i)
				primes[index++] = i;

		// Now ready to process input.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		partitions = Integer.parseInt(tok.nextToken());
		values = new int[n];
		tok = new StringTokenizer(stdin.readLine());
		for (int i=0; i<n; i++)
			values[i] = Integer.parseInt(tok.nextToken());

		// Screen for 0 answer.
		if (!possible(0))
			System.out.println(0);

		else {

			// Binary search over what is possible.
			int low = 0, high = primes.length-1;
			while (low < high-1) {
				int mid = (low+high)/2;
				if (possible(mid))
					low = mid;
				else
					high = mid-1;
			}

			// Walk the last step.
			while (low < primes.length && possible(low)) low++;
			System.out.println(primes[low-1]);
		}

	}

	public static boolean possible(int item) {

		int myPrime = primes[item];
		int minPartitions = 0;
		int index = 0;

		// Go through the array of numbers.
		while (index < n) {

			// Oops we've used too many partitions.
			if (minPartitions >= partitions) return false;

			// Can't do it if a single item fails!
			int curGCD = values[index];
			if (sieve[curGCD] < myPrime) return false;
			index++;

			// Go as far as we can.
			while (index < n) {

				// Add in the next item into our partition.
				curGCD = gcd(curGCD, values[index]);

				// Oops no can do.
				if (sieve[curGCD] < myPrime) break;

				// Add this one.
				else index++;
			}

			// We've added one partition.
			minPartitions++;
		}

		// We made it!
		return true;
	}

	public static int gcd(int a, int b) {
		if (a == 0) return b;
		if (b == 0) return a;
		return gcd(b, a%b);
	}
}