#include <bits/stdc++.h>
using namespace std;
const long long maxn = 50005 + 5;
const long long mod = 1e9 + 7;
const long long INF = 2e12;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, k;
long long a[maxn];
long long pre[maxn][35];
long long maxx[maxn * 35];
long long minx[maxn * 35];
long long cnt = 1;
long long siz[maxn * 35];
long long ans = 0;
long long tree[maxn * 35][2];
void build(long long val) {
  long long now = 1;
  siz[now]++;
  minx[now] = min(minx[now], val);
  maxx[now] = max(maxx[now], val);
  for (long long i = 32; i >= 0; i--) {
    long long p = ((val >> i) & 1ll);
    if (tree[now][p] == 0) {
      tree[now][p] = ++cnt;
    }
    now = tree[now][p];
    siz[now]++;
    minx[now] = min(minx[now], val);
    maxx[now] = max(maxx[now], val);
  }
}
long long kth;
long long Get_tot(long long val, long long v) {
  long long now = 1;
  long long res = 0;
  for (long long i = 32; i >= 0; i--) {
    if ((v >> i) & 1ll) {
      long long p = ((val >> i) & 1ll) ^ 1ll;
      if (tree[now][p] == 0) break;
      now = tree[now][p];
    } else {
      long long p = ((val >> i) & 1ll);
      if (tree[now][p ^ 1ll]) {
        res = res + siz[tree[now][p ^ 1ll]];
      }
      if (tree[now][p] == 0) break;
      now = tree[now][p];
    }
  }
  return res;
}
long long Find(long long v) {
  long long res = 0;
  for (long long i = 1; i <= n; i++) {
    res = res + Get_tot(a[i], v);
  }
  return res;
}
long long calc(long long x, long long val) {
  long long res = 0;
  long long wns1 = minx[x];
  long long wns2 = maxx[x];
  long long l = lower_bound(a + 1, a + 1 + n, wns1) - a;
  long long r = upper_bound(a + 1, a + 1 + n, wns2) - a - 1;
  for (long long i = 32; i >= 0; i--) {
    if (!((val >> i) & 1ll)) {
      res =
          (res + (1ll << i) % mod * ((pre[r][i] - pre[l - 1][i]) % mod)) % mod;
    } else {
      res = (res + (1ll << i) % mod *
                       ((r - l + 1 - pre[r][i] + pre[l - 1][i]) % mod)) %
            mod;
    }
  }
  return res % mod;
}
long long Work(long long val, long long v) {
  long long now = 1;
  long long res = 0;
  for (long long i = 32; i >= 0; i--) {
    if ((v >> i) & 1ll) {
      long long p = ((val >> i) & 1ll) ^ 1ll;
      if (tree[now][p] == 0) break;
      now = tree[now][p];
    } else {
      long long p = ((val >> i) & 1ll);
      if (tree[now][p ^ 1ll]) {
        long long wns = calc(tree[now][p ^ 1ll], val) % mod;
        res = (res + wns) % mod;
      }
      if (tree[now][p] == 0) break;
      now = tree[now][p];
    }
  }
  return res % mod;
}
long long mo[maxn];
long long moo = 0;
long long mul(long long x, long long y, long long mod) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1ll;
  }
  return res % mod;
}
signed main() {
  memset(minx, 0x3f, sizeof(minx));
  n = read(), k = read();
  k = k * 2;
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
  }
  sort(a + 1, a + 1 + n);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 32; j >= 0; j--) {
      if ((a[i] >> j) & 1ll)
        pre[i][j] = pre[i - 1][j] + 1;
      else
        pre[i][j] = pre[i - 1][j];
    }
  }
  for (long long i = 1; i <= n; i++) {
    build(a[i]);
  }
  long long l = 0, r = 2e9;
  while (l < r) {
    long long mid = (l + r) >> 1ll;
    long long wns = Find(mid);
    if (wns >= k)
      l = mid + 1;
    else
      r = mid;
  }
  kth = l;
  for (long long i = 1; i <= n; i++) {
    long long wns = Get_tot(a[i], kth);
    k -= wns;
  }
  for (long long i = 1; i <= n; i++) {
    ans = (ans + Work(a[i], kth)) % mod;
  }
  ans = (ans + k * kth) % mod;
  printf("%lld\n", ans * mul(2, mod - 2, mod) % mod);
  return 0;
}
