#include <bits/stdc++.h>
double st_tim = clock();
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
int cha[100], tp = 0;
template <class T>
void write(T x) {
  while (x) cha[++tp] = x % 10, x /= 10;
  for (int i = tp; i >= 1; --i) printf("%d", cha[i]);
  printf("\n");
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 750005;
int n;
long long k;
unsigned int a[N];
int top = 0, Top = 0;
int pref[N];
struct node {
  int l1, r1, mid1, l2, r2, mid2;
  node(int l1 = 0, int r1 = 0, int l2 = 0, int r2 = 0)
      : l1(l1), r1(r1), l2(l2), r2(r2) {}
} arr[N], tmp[N];
void add_new(int l1, int r1, int l2, int r2) {
  if ((l1 ^ r1) && (l2 ^ r2)) {
    tmp[++Top] = node(l1, r1, l2, r2);
  }
}
long long calc(int l1, int r1, int l2, int r2, long long Base) {
  long long total = 0;
  total +=
      (long long)((r1 - l1) - (pref[r1] - pref[l1])) * (pref[r2] - pref[l2]);
  total +=
      (long long)((r2 - l2) - (pref[r2] - pref[l2])) * (pref[r1] - pref[l1]);
  return total * Base;
}
void init() {
  read(n);
  read(k);
  k <<= 1;
  for (int i = 0; i < n; ++i) {
    read(a[i]);
  }
  sort(a, a + n);
}
void solve() {
  long long ans = 0;
  arr[++top] = node(0, n, 0, n);
  for (int B = 29; B >= 0; --B) {
    long long one = 0;
    for (int i = 1; i <= top; ++i) {
      arr[i].mid1 = lower_bound(a + arr[i].l1, a + arr[i].r1, (1 << B)) - a;
      arr[i].mid2 = lower_bound(a + arr[i].l2, a + arr[i].r2, (1 << B)) - a;
      one += (long long)(arr[i].mid1 - arr[i].l1) * (arr[i].r2 - arr[i].mid2);
      one += (long long)(arr[i].mid2 - arr[i].l2) * (arr[i].r1 - arr[i].mid1);
    }
    for (int i = 0; i < n; ++i) a[i] &= ((1 << B) - 1);
    if (k <= one) {
      ans += (1LL << B) * k;
      for (int i = 1; i <= top; ++i) {
        add_new(arr[i].l1, arr[i].mid1, arr[i].mid2, arr[i].r2);
        add_new(arr[i].mid1, arr[i].r1, arr[i].l2, arr[i].mid2);
      }
    } else {
      k -= one;
      ans += (1LL << B) * one;
      for (int b = 0; b < B; ++b) {
        pref[0] = 0;
        for (int i = 0; i < n; ++i) {
          pref[i + 1] = pref[i] + (a[i] >> b & 1);
        }
        for (int i = 1; i <= top; ++i) {
          ans +=
              calc(arr[i].l1, arr[i].mid1, arr[i].mid2, arr[i].r2, (1LL << b));
          ans +=
              calc(arr[i].l2, arr[i].mid2, arr[i].mid1, arr[i].r1, (1LL << b));
        }
      }
      for (int i = 1; i <= top; ++i) {
        add_new(arr[i].l1, arr[i].mid1, arr[i].l2, arr[i].mid2);
        add_new(arr[i].mid1, arr[i].r1, arr[i].mid2, arr[i].r2);
      }
    }
    if (Top > n) return;
    top = Top;
    Top = 0;
    for (int i = 1; i <= top; ++i) arr[i] = tmp[i];
  }
  ans >>= 1;
  printf("%lld\n", ans % 1000000007);
}
int main() {
  init();
  solve();
  return 0;
}
