import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdlib; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]; auto A = readln.split.map!(to!long).array; A.sort!"a > b"; long dfs(int idx, long k) { if (idx == N-1) return k % A[idx]; return max(dfs(idx+1, k%A[idx]), dfs(idx+1, k)); } dfs(0, K).writeln; }