#include <bits/stdc++.h>
using namespace std;
const int N = int(5e4) + 2;
const int logN = 29;
const int mod = int(1e9) + 7;
int n, m, cur, limit, a[N], dem[logN + 1][2], need;
long long res;
pair<long long, long long> ans;
int div2;
map<int, vector<int>> trie;
int Pow(int x, int y) {
  int res = 1;
  for (; y > 0; y >>= 1) {
    if (y & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod;
  }
  return res;
}
void upd(int x, int val) {
  for (int i = logN; i >= 0; --i) dem[i][x >> i & 1] += val;
}
int get(int x) {
  long long res = 0;
  for (int i = logN; i >= 0; --i)
    res += 1ll * dem[i][1 ^ (x >> i & 1)] * (1 << i);
  return res % mod;
}
void Get() {
  trie.clear();
  ans = make_pair(0, 0);
  need |= (1 << limit);
  for (int i = 1; i <= n; ++i) trie[a[i] & need].emplace_back(a[i]);
  int rig;
  for (auto lef : trie) {
    rig = cur ^ lef.first;
    for (int x : lef.second) upd(x, 1);
    for (int x : trie[rig]) {
      ans.first += (int)lef.second.size();
      ans.second += get(x);
      if (ans.second >= mod) ans.second -= mod;
    }
    for (int x : lef.second) upd(x, -1);
  }
  ans.first = 1ll * ans.first * div2 % mod;
  ans.second = 1ll * ans.second * div2 % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("test"
            ".inp",
            "r")) {
    freopen(
        "test"
        ".inp",
        "r", stdin);
    freopen(
        "test"
        ".out",
        "w", stdout);
  }
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  need = 0;
  div2 = Pow(2, mod - 2);
  for (int i = logN; i >= 0; --i) {
    limit = i;
    cur ^= (1 << i);
    Get();
    if (ans.first <= m) {
      res += ans.second, m -= ans.first, cur ^= (1 << i);
      if (res >= mod) res -= mod;
    }
    if (i == 0) {
      res += cur * m % mod;
      if (res >= mod) res -= mod;
    }
  }
  cout << res;
}
