Hide

Problem C
Big Totoro

/problems/bigtotoro/file/statement/en/img-0001.png
Totoro sitting on a branch

Big Totoro is currently eating big acorns. There are $N$ big acorns, each with some size $s_i$.

Big Totoro starts off at size $K$. After eating a big acorn, Big Totoro adds the size of that big acorn onto his current size. However, Big Totoro can only eat a big acorn if the big acorn and Big Totoro are the same size modulo 4. In other words, when Big Totoro’s size and the size of the big acorn are divided by 4, they have the same remainder.

After eating a big acorn, it disappears and can no longer be eaten. Calculate the maximum size Big Totoro can achieve.

Input

The first line of input contains two space-separated integers $N \: (1 \leq N \leq 10^5)$ and $K \: (0 \leq K \leq 10^4)$, denoting the number of acorns and the initial size of Big Totoro, respectively. The second line of input contains $N$ space-separated integers $s_1, s_2, \dotsc , s_N$, where each $s_i \: (0 \leq s_i \leq 10^4)$ represents the sizes of the big acorns.

Output

The first line of output should contain a single integer, representing the maximum size Big Totoro can achieve.

Sample Input 1 Sample Output 1
4 3
7 4 6 8 
28
Sample Input 2 Sample Output 2
3 5
0 8 1 
6

Please log in to submit a solution to this problem

Log in