#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 1000, OO = 1e18, M = 1e9 + 7, P = 6151, SQ = 1000, lg = 30;
long long int a[N], nxt = 2, n, m;
struct node {
  int bit[lg + 10], lch, rch, num;
} tr[N * lg];
long long int pw(int x, int y) {
  if (y == 0) return 1;
  long long int cnt = pw(x, y / 2);
  cnt = (cnt * cnt) % M;
  if (y % 2 == 1) cnt = (cnt * x) % M;
  return cnt;
}
void upd(int x) {
  int p = 1;
  for (int j = lg; j >= 0; j--)
    if (x & (1 << j)) tr[p].bit[j]++;
  for (int i = lg; i >= 0; i--) {
    if (!(x & (1 << i))) {
      if (tr[p].lch == 0) tr[p].lch = nxt++;
      tr[p].num++;
      p = tr[p].lch;
    } else {
      if (tr[p].rch == 0) tr[p].rch = nxt++;
      tr[p].num++;
      p = tr[p].rch;
    }
    for (int j = lg; j >= 0; j--)
      if (x & (1 << j)) tr[p].bit[j]++;
  }
  tr[p].num++;
}
long long int is(long long int x, long long int y) {
  int p = 1;
  long long sum = 0;
  for (int i = lg; i >= 0; i--) {
    if (!(x & (1ll << i))) {
      if (y & (1ll << i))
        p = tr[p].rch;
      else {
        sum += (1ll * tr[tr[p].rch].num);
        p = tr[p].lch;
      }
    } else {
      if (y & (1 << i))
        p = tr[p].lch;
      else {
        sum += (1ll * tr[tr[p].lch].num);
        p = tr[p].rch;
      }
    }
    if (!p) return sum;
  }
  sum += tr[p].num;
  return sum;
}
long long int get(long long int x) {
  long long int sum = 0;
  for (int i = 0; i < n; i++) sum += is(a[i], x);
  return (sum / 2);
}
long long int is_ans(long long int x, long long int y) {
  long long int p = 1, sum = 0;
  for (int i = lg; i >= 0; i--) {
    if (!(x & (1 << i))) {
      if (y & (1 << i))
        p = tr[p].rch;
      else {
        long long int r = tr[p].rch;
        for (int j = lg; j >= 0; j--) {
          if (x & (1 << j))
            sum = (sum + (1ll << j) * 1ll * (tr[r].num - tr[r].bit[j])) % M;
          else
            sum = (sum + (1ll << j) * 1ll * tr[r].bit[j]) % M;
        }
        p = tr[p].lch;
      }
    } else {
      if (y & (1 << i))
        p = tr[p].lch;
      else {
        long long int r = tr[p].lch;
        for (int j = lg; j >= 0; j--) {
          if (x & (1 << j))
            sum = (sum + (1ll << j) * 1ll * (tr[r].num - tr[r].bit[j])) % M;
          else
            sum = (sum + (1ll << j) * 1ll * tr[r].bit[j]) % M;
        }
        p = tr[p].rch;
      }
    }
    if (!p) return sum;
  }
  sum = (sum + y * 1ll * tr[p].num) % M;
  return sum;
}
long long int get_sum(long long int x) {
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += is_ans(a[i], x);
    sum %= M;
  }
  return (sum * 1ll * pw(2, M - 2)) % M;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    upd(a[i]);
  }
  long long int l = 0, r = (1ll << (lg + 1)) - 1;
  while (l < r) {
    long long int mid = (l + r) / 2;
    if (get(mid) < m)
      r = mid;
    else
      l = mid + 1;
  }
  l--;
  long long int ans = (get_sum(l + 1) + (l * (m - get(l + 1))) % M) % M;
  cout << ans << endl;
  return 0;
}
