n,k = map(int,input().split()) a = [int(i) for i in input().split()] #a.sort(reverse=True) #a = [13,11,17] #print(a) ans = k val = 0 minv = min(a) for i in range(n): tmp = ans % a[i] if tmp < minv: val = max(val,tmp) print(val)