#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10, M = N * 35 + 10, mod = 1e9 + 7;
int n;
long long k, a[N], lim, bit[N][35];
int ch[M][2], cnt, sz[M], p[N];
inline long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = a * ret % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return ret;
}
void insert(long long x) {
  int nw = 1;
  sz[nw]++;
  for (int i = 31; i >= 0; i--) {
    int c = (x >> i) & 1;
    if (!ch[nw][c]) ch[nw][c] = ++cnt;
    nw = ch[nw][c];
    sz[nw]++;
  }
}
long long getkval() {
  long long rk = k, ret = 0;
  for (int i = 1; i <= n; i++) p[i] = 1;
  for (int i = 31; i >= 0; i--) {
    long long tmp = 0;
    for (int j = 1; j <= n; j++) {
      int c = (a[j] >> i) & 1;
      tmp += sz[ch[p[j]][c ^ 1]];
    }
    if (tmp >= rk)
      ret |= (1ll << i);
    else
      rk -= tmp;
    for (int j = 1; j <= n; j++) {
      int c = ((a[j] ^ ret) >> i) & 1;
      p[j] = ch[p[j]][c];
    }
  }
  return ret;
}
void solve() {
  long long sum = 0, tot = 0;
  for (int i = 31; i >= 0; i--) {
    if ((lim >> i) & 1) continue;
    long long nw = ((lim >> i) << i) | (1ll << i);
    for (int j = 1; j <= n; j++) {
      long long l = ((a[j] ^ nw) >> i) << i, r = l | ((1ll << i) - 1);
      l = lower_bound(a + 1, a + n + 1, l) - a;
      r = upper_bound(a + 1, a + n + 1, r) - a;
      sum = (sum + nw * (r - l) % mod) % mod;
      tot += r - l;
      if (l <= j && j < r) tot--;
      for (int o = i - 1; o >= 0; o--) {
        long long tmp = bit[l][o] - bit[r][o];
        if ((a[j] >> o) & 1) tmp = r - l - tmp;
        sum = (sum + (1ll << o) * tmp % mod) % mod;
      }
    }
  }
  sum = 1ll * sum * power(2, mod - 2);
  tot >>= 1;
  k >>= 1;
  long long ans = (sum + 1ll * (k - tot) * lim % mod) % mod;
  printf("%lld\n", (ans + mod) % mod);
  return;
}
int main() {
  scanf("%d%lld", &n, &k);
  k <<= 1;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  cnt = 1;
  memset(ch, 0, sizeof(ch));
  sort(a + 1, a + n + 1);
  for (int i = n; i >= 1; i--) {
    insert(a[i]);
    for (int j = 0; j <= 31; j++) bit[i][j] = bit[i + 1][j] + ((a[i] >> j) & 1);
  }
  lim = getkval();
  solve();
  return 0;
}
