cswork / OAOpen practice workspace

MicrosoftOA #27

Get Max Or Sum

Estimated MediumJudge-ready

Topics (AI-labelled)Bits & MathPrefix & Ranges

Each operation picks one array element and multiplies it by 2, at most K times in total; maximize the bitwise OR of all elements. The resource-migration text at the start of the source has nothing to do with its explicit function and examples, so this site implements only the doubling rule.

Input

This site's ranges: the first line contains n K (1≤n≤100000, 0≤K≤30), and the second line contains n non-negative integers (0..10⁹).

Output

Output a single integer, the answer.

Example 1

Input:

2 1
12 9

Output:

30

Example 2

Input:

2 0
1 2

Output:

3

Example 3

Input:

2 3
0 0

Output:

0

Example notes

Example 1: doubling 9 gives 12 OR 18=30, which beats the 25 obtained by doubling 12.

Example 2: no operation is allowed, so the answer is 1 OR 2=3.

Example 3: doubling zero still gives zero, so the answer is 0.

Editorial

Loading solution…