#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int mod = 1e9 + 7;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
struct Mint {
  int a;
  Mint(int _a = 0) : a(_a) {}
  friend ostream &operator<<(ostream &out, const Mint &_) {
    out << _.a;
    return out;
  }
  bool operator==(const Mint &_) const { return a == _.a; }
  bool operator!() const { return !a; }
  Mint operator+(const Mint &_) const {
    int ret = a + _.a;
    return ret < mod ? Mint(ret) : Mint(ret - mod);
  }
  Mint operator-(const Mint &_) const { return *this + Mint(mod - _.a); }
  Mint operator*(const Mint &_) const { return Mint((int)((LL)a * _.a % mod)); }
  friend Mint &operator+=(Mint &a, const Mint &b) { return a = a + b; }
  friend Mint &operator-=(Mint &a, const Mint &b) { return a = a - b; }
  friend Mint &operator*=(Mint &a, const Mint &b) { return a = a * b; }
  Mint &operator++() { return *this = *this + Mint(1); }
  Mint &operator--() { return *this = *this - Mint(1); }
  template <class T>
  Mint binPow(T exp) const {
    Mint ret(1), c = *this;
    for (; exp; exp >>= 1, c *= c)
      if (exp & 1) ret *= c;
    return ret;
  }
};
vector<array<int, 30> > bit;
struct Trie {
  struct Node {
    array<int, 2> child;
    int cnt;
    array<int, 30> cntBit;
    Node() {
      fill((child).begin(), (child).end(), 0);
      cnt = 0;
      fill((cntBit).begin(), (cntBit).end(), 0);
    }
  };
  vector<Node> node;
  Trie() { node.assign(1, Node()); }
  void resetCnt() {
    for (auto &i : node) i.cnt = 0;
  }
  void ins(int pos) {
    int iNode = 0;
    for (auto i : bit[pos]) {
      if (!node[iNode].child[i]) {
        node[iNode].child[i] = ((int)(node).size());
        node.emplace_back(Node());
      }
      iNode = node[iNode].child[i];
    }
  }
  void updCnt(int pos) {
    int iNode = 0;
    for (auto i : bit[pos]) {
      iNode = node[iNode].child[i];
      ++node[iNode].cnt;
    }
  }
  void updCnt2(int pos) {
    int iNode = 0;
    for (int k = 0; k < 30; ++k) {
      iNode = node[iNode].child[bit[pos][k]];
      ++node[iNode].cnt;
      for (int i = k; i < 30; ++i)
        if (bit[pos][i]) ++node[iNode].cntBit[i];
    }
  }
} trie;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  LL m;
  cin >> n >> m;
  bit.assign(n, {});
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for (int k = 0; k < ((int)(bit[i]).size()); ++k) bit[i][k] = ((a >> k) & 1);
    reverse((bit[i]).begin(), (bit[i]).end());
    trie.ins(i);
  }
  auto cal = [&](int lim) {
    LL ret = 0;
    vector<int> tmp;
    for (int i = 0; i < 30; ++i) tmp.emplace_back((lim >> i) & 1);
    reverse((tmp).begin(), (tmp).end());
    trie.resetCnt();
    for (int i = 0; i < n; ++i) {
      int iNode = 0;
      bool flag = true;
      for (int k = 0; k < 30; ++k) {
        if (!tmp[k])
          ret += trie.node[trie.node[iNode].child[bit[i][k] ^ 1]].cnt;
        if (trie.node[iNode].child[bit[i][k] ^ tmp[k]])
          iNode = trie.node[iNode].child[bit[i][k] ^ tmp[k]];
        else {
          flag = false;
          break;
        }
      }
      if (flag) ret += trie.node[iNode].cnt;
      trie.updCnt(i);
    }
    return ret;
  };
  int l = 1, r = (1 << 30) - 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (cal(mid) < m)
      r = mid;
    else
      l = mid + 1;
  }
  Mint ans = Mint(((l - 1) % mod)) * Mint((int)((m - cal(l)) % mod));
  vector<int> tmp;
  for (int i = 0; i < 30; ++i) tmp.emplace_back((l >> i) & 1);
  reverse((tmp).begin(), (tmp).end());
  trie.resetCnt();
  function<int(int, int, int)> dfs = [&](int iNode, int k, int pos) {
    if (k == 30) return trie.node[iNode].cnt;
    int ret = 0;
    if (!tmp[k]) {
      int tmpNode = trie.node[iNode].child[bit[pos][k] ^ 1];
      ret += trie.node[tmpNode].cnt;
      for (int j = k; j < 30; ++j) {
        if (bit[pos][j])
          ans += Mint(trie.node[tmpNode].cnt - trie.node[tmpNode].cntBit[j]) *
                 Mint(((1 << (29 - j)) % mod));
        else
          ans += Mint(trie.node[tmpNode].cntBit[j]) *
                 Mint(((1 << (29 - j)) % mod));
      }
    }
    if (trie.node[iNode].child[bit[pos][k] ^ tmp[k]]) {
      int tmp2 = dfs(trie.node[iNode].child[bit[pos][k] ^ tmp[k]], k + 1, pos);
      if (tmp[k]) ans += Mint(((1 << (29 - k)) % mod)) * Mint(tmp2);
      ret += tmp2;
    }
    return ret;
  };
  for (int i = 0; i < n; ++i) {
    dfs(0, 0, i);
    trie.updCnt2(i);
  }
  cout << ans << '\n';
  return 0;
}
