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