• + 0 comments
    import math
    
    def isPrime(n) : 
        # Corner cases 
        if (n <= 1) : 
            return False
        if (n <= 3) : 
            return True
      
        # This is checked so that we can skip  
        # middle five numbers in below loop 
        if (n % 2 == 0 or n % 3 == 0) : 
            return False
      
        i = 5
        while(i * i <= n) : 
            if (n % i == 0 or n % (i + 2) == 0) : 
                return False
            i = i + 6
      
        return True
    
    n,l=map(int, input().split())
    li=list(map(int, input().split()))
    
    else:
     
        if(n==1):
            print(0)
        else:
            abc=li[0]
            for i in range(1,len(li)):
                abc=math.gcd(abc,li[i])
            
            if(l<abc):
                if(isPrime(abc)):
                    print(0)
                else:
                    for i in range(l,1,-1):
                        
                        ans2=math.gcd(i,abc)
                        if(ans2>1):
                            print(l-l%ans2)
                            break
                
            else:
                ans=l%abc
                
            
    
                ans1=l-ans
                print(ans1)