#include <bits/stdc++.h>
using namespace std;
const int maxn = 50005, B = 30, p = 1000000007, N = maxn * 30;
int n, bas, ans, i, j, k, pre, a[maxn], b[maxn], sum[maxn][B], l[N], r[N],
    c[N][2], tot, x, sg;
long long m, tmp;
void S(int &x, int y) {
  x += y;
  if (x >= p) x -= y;
}
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  sort(a + 1, a + n + 1);
  tot = 1;
  l[1] = 1;
  r[1] = n;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < B; j++) sum[i][j] = sum[i - 1][j] + (a[i] >> j & 1);
    pre = 1;
    b[i] = 1;
    for (j = B - 1; j >= 0; j--) {
      if (!c[pre][a[i] >> j & 1]) c[pre][a[i] >> j & 1] = ++tot, l[tot] = i;
      pre = c[pre][a[i] >> j & 1];
      r[pre] = i;
    }
  }
  for (i = B - 1; i >= 0; i--) {
    tmp = 0;
    bas ^= 1 << i;
    for (j = 1; j <= n; j++)
      if ((a[j] ^ bas) < a[j] && (x = c[b[j]][(a[j] >> i & 1) ^ 1]))
        tmp += r[x] - l[x] + 1;
    if (tmp > m) {
      for (j = 1; j <= n; j++) b[j] = c[b[j]][(a[j] >> i & 1) ^ 1];
    } else {
      m -= tmp;
      for (j = 1; j <= n; j++) {
        sg = a[j] >> i & 1;
        if ((a[j] ^ bas) < a[j] && (x = c[b[j]][sg ^ 1]))
          for (k = 0; k < B; k++) {
            if (a[j] >> k & 1)
              ans = (ans + (1LL << k) * (sum[l[x] - 1][k] - sum[r[x]][k] +
                                         r[x] - l[x] + 1)) %
                    p;
            else
              ans = (ans + (1LL << k) * (sum[r[x]][k] - sum[l[x] - 1][k])) % p;
          }
        b[j] = c[b[j]][sg];
      }
      bas ^= 1 << i;
    }
  }
  ans = (ans + 1LL * bas * m) % p;
  cout << ans << endl;
  return 0;
}
