#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = 3.1415926535897932;
const int dir[8][2] = {-1, -1, -1, 0, -1, 1, 0, -1, 0, 1, 1, -1, 1, 0, 1, 1};
const int maxn = 5e4 + 5;
const int MOD = 1e9 + 7;
int trie[maxn * 200][2], pn = 1;
int s[35][maxn][2];
long long n, K;
int w[maxn];
int L[maxn * 200], R[maxn * 200];
int point[maxn];
int knum;
const int base = 30;
void insert(int x, int id) {
  int p = 1;
  L[p] = min(L[p], id);
  R[p] = max(R[p], id);
  for (int i = base; i >= 0; i--) {
    int idx = x >> i & 1;
    if (!trie[p][idx]) trie[p][idx] = ++pn;
    p = trie[p][idx];
    L[p] = min(L[p], id);
    R[p] = max(R[p], id);
  }
}
int siz(int p) { return max(R[p] - L[p] + 1, 0); }
void get_K_val() {
  long long k = K;
  for (int i = 1; i <= n; i++) point[i] = 1;
  for (int i = base; i >= 0; i--) {
    long long cnt = 0;
    for (int j = 1; j <= n; j++)
      cnt += siz(trie[point[j]][(w[j] >> i & 1) ^ 1]);
    for (int j = 1; j <= n; j++)
      point[j] = trie[point[j]][(w[j] >> i & 1) ^ (cnt >= k)];
    if (cnt >= k)
      knum |= (1 << i);
    else
      k -= cnt;
  }
}
int calc(int l, int r, int val) {
  if (l > r || !l) return 0;
  long long ans = 0;
  for (int i = base; i >= 0; i--) {
    int idx = val >> i & 1;
    long long t =
        1LL * (s[i][r][idx ^ 1] - s[i][l - 1][idx ^ 1]) * (1 << i) % MOD;
    ans = (ans + t) % MOD;
  }
  return ans;
}
int solve() {
  long long ans = 1LL * knum * K % MOD;
  for (int i = 1; i <= n; i++) point[i] = 1;
  for (int i = base; i >= 0; i--) {
    int idx = knum >> i & 1;
    if (idx == 0) {
      for (int j = 1; j <= n; j++) {
        int p = trie[point[j]][(w[j] >> i & 1) ^ 1];
        int res = calc(L[p], R[p], w[j]) - 1LL * siz(p) * knum % MOD;
        res %= MOD;
        ans = (ans + res) % MOD;
      }
    }
    for (int j = 1; j <= n; j++)
      point[j] = trie[point[j]][(w[j] >> i & 1) ^ idx];
  }
  return ans;
}
int main() {
  scanf("%lld%lld", &n, &K);
  K <<= 1;
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  sort(w + 1, w + 1 + n);
  for (int i = 0; i <= base; i++) {
    for (int j = 1; j <= n; j++) {
      s[i][j][0] = s[i][j - 1][0] + 1 - (w[j] >> i & 1);
      s[i][j][1] = s[i][j - 1][1] + (w[j] >> i & 1);
    }
  }
  memset(L, 63, sizeof(L));
  for (int i = 1; i <= n; i++) insert(w[i], i);
  get_K_val();
  long long ans = solve();
  ans = ans * (MOD + 1) / 2 % MOD;
  ans = (ans + MOD) % MOD;
  printf("%lld\n", ans);
  return 0;
}
