import java.util.*; public class Main { static int n; static int[] values; static int max = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int k = sc.nextInt(); values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } search(k, 0, new boolean[n]); System.out.println(max); } static void search(int value, int idx, boolean[] used) { if (idx == n) { max = Math.max(max, value); return; } for (int i = 0; i < n; i++) { if (used[i]) { continue; } used[i] = true; search(value % values[i], idx + 1, used); used[i] = false; } } }