Problem Description
Peanut's endless fascination with pies has ended up with him organising a huge pie party! As the party name suggests, Peanut will buy MANY MANY pies and then eat them! Pies are extremely awesome, but Peanut has found a way to make pies EVEN MORE AWESOME! The awesomeness of the huge pie party is defined by the awesomeness index of the pies.
At the pie party, the pies will be arranged into a row. There are N different types of pie Peanut can order, each of them with a different size. Peanut can order any amount of each type of pie for the party, but the total number of pies for the party must be equal to P. Since the pies will be arranged in a row, some pairs of pies will be adjacent to each other. Take two adjacent pies with size A and B. The awesomeness index of this pair of pies will be defined as A xor B. The awesomeness index of this entire chain of pies will be the sum of the awesomeness index of all adjacent pairs of pies.
Given the sizes of pies Peanut can order, output the maximum awesomeness index of the pies if Peanut chooses and arranges the pies optimally.
Input
The first line of input will contain two integers,
N and
P.
The second line of input will contain
N integers, with each integer representing the size of one possible type of pie Peanut can buy.
Output
Your output should contain one integer, the maximum awesomeness index of the pies.
Limits
Subtask 1 (13%): 1 ≤ N, P ≤ 10. All of the pie sizes will less than 10.
Subtask 2 (19%): 1 ≤ N, P ≤ 1000. All of the pie sizes will be less than 1024.
Subtask 3 (25%): 1 ≤ N, P ≤ 100000. All of the pie sizes will be less than 1024.
Subtask 4 (43%): 1 ≤ N ≤ 100000. 1 ≤ P ≤ 2
31-1. All of the pie sizes will fit into a 32-bit signed integer.
Subtask 5 (0%): As per sample testcases.
Sample Input 1
4 2
2 3 5 7
Sample Output 1
7
Explanation of Sample 1
Arranging it in the form 5 -- 2 will give an awesomeness index of 7 (2 xor 5).