#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007;
long long pow_mod(long long x, long long n) {
  long long s = 1;
  for (; n; n >>= 1) {
    if (n & 1) s = s * x % p;
    x = x * x % p;
  }
  return s;
}
const int N = 30;
int n;
long long K;
int w[50010], sum[50010][31][2];
struct Trie {
  int nxt[2], sz;
} T[50010 * 32];
int rt = 1, top = 1;
void insert(int x) {
  int now = rt;
  for (int i = N; ~i; --i) {
    int ch = x >> i & 1;
    if (!T[now].nxt[ch]) T[now].nxt[ch] = ++top;
    now = T[now].nxt[ch];
    ++T[now].sz;
  }
}
int a[50010], b[50010];
long long ans, Ans;
int main() {
  scanf("%d%lld", &n, &K);
  K *= 2;
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]), insert(w[i]);
  sort(w + 1, w + n + 1);
  for (int j = 0; j <= N; ++j)
    for (int i = 1; i <= n; ++i) {
      sum[i][j][0] = sum[i - 1][j][0];
      sum[i][j][1] = sum[i - 1][j][1];
      ++sum[i][j][w[i] >> j & 1];
    }
  for (int i = 1; i <= n; ++i) a[i] = rt;
  for (int k = N; ~k; --k) {
    long long s = 0;
    for (int i = 1; i <= n; ++i) {
      bool tag = w[i] >> k & 1;
      s += T[T[a[i]].nxt[tag ^ 1]].sz;
    }
    if (K <= s) {
      ans = (ans + (1ll << k) * K) % p;
      for (int i = 1; i <= n; ++i) {
        int tag = w[i] >> k & 1;
        a[i] = T[a[i]].nxt[tag ^ 1];
        b[i] |= (tag ^ 1) << k;
      }
    } else {
      K -= s;
      for (int i = 1; i <= n; ++i) {
        bool tag = w[i] >> k & 1;
        int l, r;
        if (tag)
          l = b[i], r = b[i] | (1 << k) - 1;
        else
          l = b[i] | 1 << k, r = l | (1 << k) - 1;
        l = lower_bound(w + 1, w + n + 1, l) - w;
        r = upper_bound(w + 1, w + n + 1, r) - w - 1;
        for (int j = 0; j <= k; ++j) {
          bool F = (w[i] >> j & 1) ^ 1;
          ans =
              (ans + (long long)(sum[r][j][F] - sum[l - 1][j][F]) * (1 << j)) %
              p;
        }
        a[i] = T[a[i]].nxt[tag];
        b[i] |= tag << k;
      }
    }
  }
  cout << ans * pow_mod(2, p - 2) % p << endl;
  return 0;
}
