#include <bits/stdc++.h>
const int N = 5e4 + 9;
const int MOD = 1e9 + 7;
const int LOG = 33;
int n, m;
int a[N];
int bit[LOG];
int bitn;
int tot = 1;
int tr[N * LOG][2];
unsigned short size[N * LOG];
unsigned short bitsum[N * LOG][LOG][2];
inline int new_node() {
  ++tot;
  memset(tr[tot], 0, sizeof tr[tot]);
  size[tot] = 0;
  return tot;
}
inline void get_bit(unsigned x) {
  bitn = 0;
  memset(bit, 0, sizeof bit);
  while (x) {
    bit[bitn++] = x & 1;
    x >>= 1;
  }
  bitn = LOG;
}
inline void insert(unsigned x) {
  get_bit(x);
  int cur = 1;
  size[cur]++;
  for (int i = 0; i < LOG; ++i) bitsum[cur][i][bit[i]]++;
  while (bitn--) {
    int b = bit[bitn];
    if (tr[cur][b])
      cur = tr[cur][b];
    else
      cur = tr[cur][b] = new_node();
    size[cur]++;
    for (int i = 0; i < LOG; ++i) bitsum[cur][i][bit[i]]++;
  }
}
inline void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    insert(a[i]);
  }
}
inline int calc(unsigned x, int *xbit) {
  get_bit(x);
  int cur = 1, ret = 0;
  while (bitn--) {
    int b = bit[bitn], xb = xbit[bitn];
    if (xb == 0) {
      ret += size[tr[cur][b ^ 1]];
      cur = tr[cur][b];
    } else
      cur = tr[cur][b ^ 1];
  }
  ret += size[cur];
  return ret;
}
inline int count(unsigned x) {
  get_bit(x);
  unsigned ret = 0;
  int xbit[LOG];
  memcpy(xbit, bit, sizeof bit);
  for (int i = 1; i <= n; ++i) ret += calc(a[i], xbit);
  ret >>= 1;
  return ret;
}
inline int calc_sum(unsigned x, int *xbit) {
  get_bit(x);
  int cur = 1, ret = 0;
  while (bitn--) {
    int b = bit[bitn], xb = xbit[bitn];
    if (xb == 0) {
      for (int i = 0; i < LOG; ++i)
        ret = (ret + (1ll << i) * bitsum[tr[cur][b ^ 1]][i][bit[i] ^ 1]) % MOD;
      cur = tr[cur][b];
    } else
      cur = tr[cur][b ^ 1];
  }
  return ret;
}
inline int count_sum(unsigned x) {
  get_bit(x);
  int ret = 0, xbit[LOG];
  memcpy(xbit, bit, sizeof bit);
  for (int i = 1; i <= n; ++i) ret = (ret + calc_sum(a[i], xbit)) % MOD;
  return ret * 500000004ll % MOD;
}
inline int work(unsigned x, int res) {
  int ans = 1ll * (res - count(x + 1)) * x % MOD;
  ans = (ans + count_sum(x)) % MOD;
  return ans;
}
inline void solve() {
  unsigned l = 0, r = INT_MAX;
  while (l < r) {
    unsigned mid = (l + r + 1) >> 1;
    if (count(mid) >= m)
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", work(l, m));
}
int main() {
  init();
  solve();
  return 0;
}
