#include <bits/stdc++.h>
using namespace std;
struct Trie {
  int ch[2], cnt[31], sz;
} t[50010 * 32];
int li[100], len, sz, a[50010], root;
void ins(int w) {
  bool b[31], c;
  int x = root;
  for (int i = 0; i < 31; i++) b[i] = w >> i & 1;
  for (int i = 31 - 1; i >= 0; i--) {
    c = b[i];
    for (int j = 0; j < 31; j++) t[x].cnt[j] += b[j];
    t[x].sz++;
    if (!t[x].ch[c]) t[x].ch[c] = ++sz;
    x = t[x].ch[c];
  }
  for (int i = 0; i < 31; i++) t[x].cnt[i] += b[i];
  t[x].sz++;
}
long long count(int w) {
  bool c;
  int x = root;
  long long res = 0;
  for (int i = 1; i <= len; i++) {
    c = w >> (31 - i) & 1;
    if (!li[i])
      res += t[t[x].ch[!c]].sz, x = t[x].ch[c];
    else
      x = t[x].ch[!c];
    if (!x) break;
  }
  return res + t[x].sz;
}
int n;
long long m, rem;
int calc(int w) {
  bool b[31];
  int res = 0, x = root;
  for (int i = 31 - 1; i >= 0; i--) b[i] = w >> i & 1;
  for (int i = 1; i <= len; i++) {
    bool c = li[i] ^ b[31 - i];
    if (!li[i]) {
      int y = t[x].ch[!c];
      rem -= t[t[x].ch[!c]].sz;
      for (int j = 31 - 1; j >= 0; j--)
        res = (res +
               ((long long)(b[j] ? t[y].sz - t[y].cnt[j] : t[y].cnt[j]) << j)) %
              1000000007;
    }
    x = t[x].ch[c];
    if (!x) break;
  }
  return res;
}
int fin;
int main() {
  scanf("%d%I64d", &n, &m), root = sz = 1, m *= 2;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), ins(a[i]);
  for (int i = 31 - 1; i >= 0; i--) {
    long long res = 0;
    li[++len] = 1;
    for (int j = 1; j <= n; j++) res += count(a[j]);
    if (m > res) li[len] = 0;
    fin = fin << 1 | li[len];
  }
  int ans = 0, iv2 = (1000000007 + 1) / 2;
  rem = m;
  for (int i = 1; i <= n; i++) {
    ans += calc(a[i]);
    if (ans >= 1000000007) ans -= 1000000007;
  }
  ans = (ans + rem * fin) % 1000000007;
  printf("%d\n", 1ll * ans * iv2 % 1000000007);
  return 0;
}
