#include <bits/stdc++.h>
using namespace std;
const int MAX = 50000 + 10;
const int Mod = 1000000007;
int bit(int a, int i) { return (a >> (30 - i)) & 1; }
int change1(int a, int i) { return a | (1 << (30 - i)); }
int change0(int a, int i) { return a & (~(1 << (30 - i))); }
int n, a[MAX], ANS;
long long m;
struct Trie {
  int ch[2], size, sum[31];
  Trie() {
    ch[0] = ch[1] = size = 0;
    memset(sum, 0, sizeof sum);
  }
} tree[MAX * 30];
int cnt, Root;
void insert(int a) {
  int now = Root, i, id, j;
  for (j = 1; j <= 30; ++j)
    if (bit(a, j)) ++tree[Root].sum[j];
  ++tree[Root].size;
  for (i = 1; i <= 30; ++i) {
    if (!tree[now].ch[id = bit(a, i)]) tree[now].ch[id] = ++cnt;
    now = tree[now].ch[id];
    ++tree[now].size;
    for (j = 1; j <= 30; ++j)
      if (bit(a, j)) ++tree[now].sum[j];
  }
}
int ask(int u, int len) {
  int now = Root, i;
  for (i = 1; i <= len; ++i)
    if (!(now = tree[now].ch[bit(u, i)])) return 0;
  return tree[now].size;
}
void dfs(int now, int nowdep, int u, int len, int A) {
  if (!now) return;
  if (nowdep == len + 1) {
    for (int i = 1; i <= 30; ++i) {
      int p = (1 << (30 - i)), size = tree[now].sum[i];
      if (bit(A, i)) size = tree[now].size - tree[now].sum[i];
      ANS = (ANS + (long long)size * p % Mod) % Mod;
    }
    return;
  }
  int id = bit(u ^ A, nowdep);
  dfs(tree[now].ch[id], nowdep + 1, u, len, A);
}
int power(long long c, int b) {
  long long k = 1;
  while (b) {
    if (b % 2 == 1) k = k * c % Mod;
    c = c * c % Mod;
    b /= 2;
  }
  return k;
}
int main() {
  int i, j;
  cin >> n >> m;
  m *= 2;
  Root = ++cnt;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    insert(a[i]);
  }
  int pre = 0;
  for (i = 1; i <= 30; ++i) {
    int sum = 0;
    pre = change1(pre, i);
    for (j = 1; j <= n; ++j) sum += ask(pre ^ a[j], i);
    if (sum <= m) {
      for (j = 1; j <= n; ++j) dfs(Root, 1, pre, i, a[j]);
      m -= sum;
      pre = change0(pre, i);
    }
  }
  ANS = (ANS + (long long)m % Mod * pre % Mod) % Mod;
  printf("%d\n", (int)((long long)ANS * power(2, Mod - 2) % Mod));
  return 0;
}
