#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c = getchar();
  T fh = 0;
  bool f = false;
  while (!isdigit(c)) f |= (c == '-'), c = getchar();
  while (isdigit(c)) fh = (fh << 1) + (fh << 3) + (c ^ 48), c = getchar();
  x = f ? -fh : fh;
  return;
}
const int N = 5e4 + 5;
int ch[N * 32][2], rt[N];
int l[N * 32], r[N * 32];
long long sum[N][32][2], k;
int n, tot = 1;
long long a[N];
void insert(int val, int xb) {
  int p = 1;
  for (int i = (31); i >= (0); --i) {
    int nw = val >> i & 1;
    if (!ch[p][nw]) ch[p][nw] = ++tot, l[tot] = xb;
    p = ch[p][nw];
    r[p] = xb;
  }
}
int pi[N], tmp[N];
const int mod = 1e9 + 7;
long long qp(long long x, long long cs) {
  long long s = 1;
  while (cs) {
    if (cs & 1) s = (s * x) % mod;
    x = (x * x) % mod;
    cs >>= 1;
  }
  return s;
}
int main() {
  read(n), read(k);
  k *= 2;
  for (int i = (1); i <= (n); ++i) read(a[i]);
  sort(a + 1, a + n + 1);
  int rt = 1;
  for (int i = (1); i <= (n); ++i) insert(a[i], i);
  for (int i = (1); i <= (n); ++i)
    for (int j = (0); j <= (31); ++j) {
      sum[i][j][0] = sum[i - 1][j][0];
      sum[i][j][1] = sum[i - 1][j][1];
      sum[i][j][a[i] >> j & 1]++;
    }
  for (int i = (1); i <= (n); ++i) pi[i] = 1;
  long long s1 = 0;
  for (int i = (31); i >= (0); --i) {
    long long tt = 0;
    for (int j = (1); j <= (n); ++j)
      if (ch[pi[j]][(a[j] >> i & 1) ^ 1])
        tt += r[ch[pi[j]][(a[j] >> i & 1) ^ 1]] -
              l[ch[pi[j]][(a[j] >> i & 1) ^ 1]] + 1;
    if (tt >= k) {
      s1 += (1ll << i);
      for (int j = (1); j <= (n); ++j) pi[j] = ch[pi[j]][(a[j] >> i & 1) ^ 1];
    } else {
      k -= tt;
      for (int j = (1); j <= (n); ++j) pi[j] = ch[pi[j]][a[j] >> i & 1];
    }
  }
  long long sm = s1 * k;
  for (int i = (1); i <= (n); ++i) pi[i] = 1;
  for (int i = (31); i >= (0); --i) {
    if (s1 >> i & 1) {
      for (int j = (1); j <= (n); ++j) pi[j] = ch[pi[j]][(a[j] >> i & 1) ^ 1];
    } else {
      for (int j = (1); j <= (n); ++j) {
        int xb = ch[pi[j]][(a[j] >> i & 1) ^ 1];
        if (xb)
          for (int k = (31); k >= (0); --k) {
            long long tm = (sum[r[xb]][k][(a[j] >> k & 1) ^ 1] -
                            sum[l[xb] - 1][k][(a[j] >> k & 1) ^ 1]) *
                           ((1ll << k) % mod) % mod;
            sm = (sm + tm) % mod;
          }
      }
      for (int j = (1); j <= (n); ++j) pi[j] = ch[pi[j]][a[j] >> i & 1];
    }
  }
  printf("%lld\n", sm * qp(2, mod - 2) % mod);
  return 0;
}
