import java.util.Scanner; public class Main { static int n, k, n2; static int[] a, memo; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } sc.close(); n2 = 1 << n; memo = new int[n2]; int ans = dfs(k, 0); System.out.println(ans); } static int dfs(int x, int bit) { if (x <= memo[bit]) { return memo[bit]; } if (bit == n2 - 1) { return x; } int max = 0; for (int i = 0; i < n; i++) { if ((bit >> i & 1) == 0) { int val = dfs(x % a[i], bit + (1 << i)); max = Math.max(max, val); } } memo[bit] = Math.max(memo[bit], max); return memo[bit]; } }