import java.util.*; public class Main { static final int MOD = 1000000007; static int n; static int k; static int[] arr; static int[][] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } dp = new int[n][1 << n]; for (int[] arr : dp) { Arrays.fill(arr, -1); } int max = 0; for (int i = 0; i < n; i++) { max = Math.max(max, dfw(i, (1 << n) - 1)); } System.out.println(max); } static int dfw(int idx, int mask) { if (dp[idx][mask] == -1) { int next = (mask ^ (1 << idx)); if (next == 0) { dp[idx][mask] = k % arr[idx]; } else { for (int i = 0; i < n; i++) { if ((next & (1 << i)) == 0) { continue; } dp[idx][mask] = Math.max(dp[idx][mask], dfw(i, next) % arr[idx]); } } } return dp[idx][mask]; } }