#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 5, mod = 1e9 + 7;
int n, a[N], b[N][30];
int64_t m, Sum;
int64_t Count(int prefix, int i) {
  int lx, rx, l, r, tmp;
  int64_t res = 0;
  Sum = 0;
  for (int z = i - 1, loop = 0; z >= loop; --z)
    for (int j = n, loop = 1; j >= loop; --j)
      b[j][z] = b[j + 1][z] + ((a[j] >> z) & 1);
  for (int j = 1, loop = n; j <= loop; ++j) {
    lx = ((prefix ^ a[j]) >> i) << i;
    rx = lx | ((1 << i) - 1);
    l = lower_bound(a + 1, a + 1 + n, lx) - a;
    r = upper_bound(a + 1, a + 1 + n, rx) - a;
    res += r - l - (lx <= a[j] && a[j] <= rx);
    for (int z = i - 1, loop = 0; z >= loop; --z) {
      tmp = b[l][z] - b[r][z];
      if ((a[j] >> z) & 1) tmp = r - l - tmp;
      Sum = (Sum + (1LL << z) * tmp % mod) % mod;
    }
  }
  Sum = (Sum + res * prefix % mod) % mod;
  return res / 2;
}
int64_t pw(int64_t a, int n) {
  if (n == 1) return a;
  int64_t res = pw(a, n >> 1);
  res = res * res % mod;
  return (n & 1) ? res * a % mod : res;
}
int main() {
  ios::sync_with_stdio();
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1, loop = n; i <= loop; ++i) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int prefix = 0;
  int64_t cnt, ans = 0;
  for (int i = 29, loop = 0; i >= loop; --i) {
    prefix |= 1 << i;
    cnt = Count(prefix, i);
    if (cnt <= m) {
      m -= cnt;
      ans = (ans + Sum) % mod;
      prefix ^= 1 << i;
    }
  }
  cout << (ans * pw(2, mod - 2) % mod + prefix * m % mod) % mod;
}
