using System; using System.Collections.Generic; using System.Linq; namespace Problem1083 { class Program { static void Main(string[] args) { var buff = GetLongArray(); long K = buff[1]; var A = GetLongList(); Console.WriteLine(Solver(K, A)); } static long Solver (long k, List list) { if (list.FindIndex(x => x <= k) == -1) { return k; } else { long temp = 0; long max = 0; for(int i = 0; i < list.Count; i++) { if(list[i] <= k) { temp = Solver(k % list[i], list); max = max < temp ? temp : max; } } return max; } } public static int GetInt() => int.Parse(Console.ReadLine()); public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static double GetDouble() => double.Parse(Console.ReadLine()); public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray(); public static List GetLongList() => Console.ReadLine().Split().Select(long.Parse).ToList(); public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray(); } }