You are given an array A that contains N elements and an integer K that represents the value of a non-empty subsequence B1,B2,…,Bm of A is defined as (B1∧K)∧(B2∧K)∧…∧(Bm∧K)⋅gcd (B1,B2,…,Bm) (where ∧ is the XOR operator). Determine the maximum value of any non-empty subsequence in the given array.
For example, if the elements of array A is [2, 4, 6] and K is 6, then the maximum value is achieved you select the subsequence [2,4]. In this case, the value of the subsequence will be ((2∧6)∧(4∧6))∗gcd (2,4)=6∗2=12.
Note: A sequence b is a subsequence of a sequence a if b can be obtained from a by deleting several (possibly zero) elements. For this question, assume that if the sequence has a single element, then the gcd is the element itself.
Input format
Output format
Print the maximum value of any non-empty subsequence of the given array.
In the given example it is clear that when we chose the subsequence containing only 6, we get the maximum value. Here gcd of elements in subsequence is 6 and K is 3. So, value = (6 ^ 3) * (6) = 5 * 6 = 30.