Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

B. Friends

time limit per test

6 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou have *n* friends and you want to take *m* pictures of them. Exactly two of your friends should appear in each picture and no two pictures should contain the same pair of your friends. So if you have *n* = 3 friends you can take 3 different pictures, each containing a pair of your friends.

Each of your friends has an attractiveness level which is specified by the integer number *a*_{i} for the *i*-th friend. You know that the attractiveness of a picture containing the *i*-th and the *j*-th friends is equal to the exclusive-or (*xor* operation) of integers *a*_{i} and *a*_{j}.

You want to take pictures in a way that the total sum of attractiveness of your pictures is maximized. You have to calculate this value. Since the result may not fit in a 32-bit integer number, print it modulo 1000000007 (10^{9} + 7).

Input

The first line of input contains two integers *n* and *m* — the number of friends and the number of pictures that you want to take.

Next line contains *n* space-separated integers *a*_{1}, *a*_{2}, ..., *a*_{n} (0 ≤ *a*_{i} ≤ 10^{9}) — the values of attractiveness of the friends.

Output

The only line of output should contain an integer — the optimal total sum of attractiveness of your pictures.

Examples

Input

3 1

1 2 3

Output

3

Input

3 2

1 2 3

Output

5

Input

3 3

1 2 3

Output

6

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/24/2020 08:55:34 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|