#include <bits/stdc++.h>
using namespace std;
const int maxN = 900005;
const int maxA = 100005;
int n, a[maxA];
long long m, ans;
int f[maxN][2], d[maxN], s[maxN], size[maxN];
int tot, c[maxN][31][2];
const int Mod = 1000000007;
int mul(long long x, long long y) {
  x *= y;
  if (x >= Mod) x %= Mod;
  return x;
}
void add(long long &x, int y) {
  x += y;
  if (x >= Mod) x -= Mod;
}
void add(int &x, int y) {
  x += y;
  if (x >= Mod) x -= Mod;
}
void Init() {
  scanf("%d%I64d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  m <<= 1;
}
int power(int x, int k) {
  int s = 1;
  while (k) {
    if (k & 1) s = mul(s, x);
    k >>= 1;
    x = mul(x, x);
  }
  return s;
}
void dfs(int u) {
  for (int k = 0; k <= 1; ++k) {
    int v = f[u][k];
    if (v) {
      d[v] = d[u] - 1;
      dfs(v);
      size[u] += size[v];
      for (int j = 0; j <= 30; ++j)
        for (int t = 0; t <= 1; ++t) c[u][j][t] += c[v][j][t];
      c[u][d[u]][k] += size[v];
    }
  }
}
long long query(int k, int dep, long long &tmp) {
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int r = 0;
    for (int j = 30; j >= dep; --j) {
      int t = ((k >> j) & 1) ^ ((a[i] >> j) & 1);
      if (!f[r][t]) goto die;
      r = f[r][t];
    }
    cnt += size[r];
    add(tmp, mul(k, size[r]));
    for (int j = 0; j <= 30; ++j)
      add(tmp, ((long long)c[r][j][((a[i] >> j) & 1) ^ 1] << j) % Mod);
  die:;
  }
  return cnt;
}
void Work() {
  for (int i = 1; i <= n; ++i) {
    int r = 0;
    for (int j = 30; j >= 0; --j) {
      int k = (a[i] >> j) & 1;
      if (f[r][k])
        r = f[r][k];
      else {
        ++tot;
        f[r][k] = tot;
        r = tot;
      }
    }
    size[r]++;
  }
  d[0] = 30;
  dfs(0);
  int k = 0;
  long long tmp = 0;
  for (int i = 30; i >= 0; --i) {
    k = k + (1 << i);
    tmp = 0;
    long long v = query(k, i, tmp);
    if (v <= m) {
      m -= v;
      add(ans, tmp);
      k -= 1 << i;
    }
  }
  tmp = 0;
  long long v = query(k, 0, tmp);
  add(ans, mul(mul(tmp, power(v, Mod - 2)), m));
  printf("%d\n", mul(ans, power(2, Mod - 2)));
}
int main() {
  Init();
  Work();
  return 0;
}
