#include <bits/stdc++.h>
namespace IO {
char ch = '\n';
template <class T>
inline T ReadInt() {
  T x(0);
  bool f(1);
  while (ch < '0' || '9' < ch) {
    if (ch == '-') {
      f = 0;
    }
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f ? x : -x;
}
template <class T>
inline T ReadUInt() {
  T x(0);
  while (ch < '0' || '9' < ch) {
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x;
}
inline double ReadDouble() {
  long long int_num = ReadInt<long long>();
  if (ch == '.') {
    double pow10 = 1, result = int_num;
    ch = getchar();
    while ('0' <= ch && ch <= '9') {
      pow10 /= 10.0;
      result += pow10 * (ch ^ 48);
      ch = getchar();
    }
    return result;
  } else {
    return (double)int_num;
  }
}
inline void ReadT(int &x) { x = ReadInt<int>(); }
inline void ReadT(long long &x) { x = ReadInt<long long>(); }
inline void ReadT(bool &x) { x = ReadUInt<bool>(); }
inline void ReadT(unsigned int &x) { x = ReadUInt<unsigned int>(); }
inline void ReadT(unsigned long long &x) { x = ReadUInt<unsigned long long>(); }
inline void ReadT(double &x) { x = ReadDouble(); }
inline void ReadT(char &s) {
  for (; isspace(ch) && (~ch); ch = getchar())
    ;
  s = ch;
  ch = '\n';
}
inline void ReadT(char *s) {
  int len(0);
  for (; isspace(ch) && (~ch); ch = getchar())
    ;
  for (; !isspace(ch) && (~ch); ch = getchar()) {
    s[len++] = ch;
  }
  s[len] = '\0';
  ch = '\n';
}
template <typename T>
inline void Read(T &t) {
  ReadT(t);
}
template <typename T, typename... Args>
void Read(T &t, Args &...args) {
  ReadT(t);
  Read(args...);
}
template <typename T>
void WriteInt(T x) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (9 < x) {
    WriteInt(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename T>
void WriteUInt(T x) {
  if (9 < x) {
    WriteInt(x / 10);
  }
  putchar(x % 10 + '0');
}
void WriteDouble(long double x, int len) {
  WriteInt((long long)x);
  if (len) {
    x -= (int)x;
    putchar('.');
    if (!x) {
      while (len--) {
        putchar(48);
      }
      return;
    }
    while (len--) {
      x *= 10;
    }
    WriteInt((long long)round(x));
  }
}
template <typename T>
inline void WriteT(T x);
template <>
inline void WriteT<int>(int x) {
  WriteInt<int>(x);
}
template <>
inline void WriteT<long long>(long long x) {
  WriteInt<long long>(x);
}
template <>
inline void WriteT<bool>(bool x) {
  WriteUInt<bool>(x);
}
template <>
inline void WriteT<unsigned int>(unsigned int x) {
  WriteUInt<unsigned int>(x);
}
template <>
inline void WriteT<unsigned long long>(unsigned long long x) {
  WriteUInt<unsigned long long>(x);
}
template <>
inline void WriteT<double>(double x) {
  WriteDouble(x, 6);
}
template <>
inline void WriteT<char *>(char *s) {
  int len(strlen(s));
  while (len--) {
    putchar(*s++);
  }
}
template <>
inline void WriteT<const char *>(const char *s) {
  while (*s) {
    putchar(*s++);
  }
}
template <>
inline void WriteT<char>(char x) {
  putchar(x);
}
template <typename T>
inline void Write(T t) {
  WriteT(t);
}
template <typename T, typename... Args>
void Write(T t, Args... args) {
  WriteT(t);
  Write(args...);
}
template <typename T>
inline void Writeln(T t) {
  WriteT(t);
  puts("");
}
template <typename T, typename... Args>
inline void Writeln(T t, Args... args) {
  WriteT(t);
  Write(args...);
  puts("");
}
inline void Writeln() { puts(""); }
const char NUMBER[36] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
                         '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
                         'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
                         'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
template <typename T>
void WriteK(T x, int p) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (p <= x) {
    WriteK(x / p, p);
  }
  putchar(NUMBER[x % p]);
}
}  // namespace IO
using namespace IO;
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 5e4 + 5;
int n, root;
long long k;
int arr[MAXN];
int bit_sum[MAXN][32];
long long Pow(long long a, long long b, long long mod = MOD) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result *= a;
      result %= mod;
    }
    a *= a;
    a %= mod;
    b /= 2;
  }
  return result;
}
long long GetSum(int num, int left, int right) {
  if (left == 0) {
    return 0;
  }
  long long result = 0;
  for (int i = 0; i <= 30; ++i) {
    long long len = bit_sum[right][i] - bit_sum[left - 1][i];
    if (num & (1 << i)) {
      len = right - left + 1 - len;
    }
    result += (len * (1ll << i)) % MOD;
    result %= MOD;
  }
  return result;
}
const int LOG_NUM = 30;
struct Trie {
  int son[2], size, left, right;
} trie[MAXN * (LOG_NUM + 1)];
int trie_cnt = 0;
void PushUp(int now) {
  trie[now].size = trie[trie[now].son[0]].size + trie[trie[now].son[1]].size;
}
void Insert(int num, int id, int &now, int deep = LOG_NUM) {
  if (!now) {
    trie[now = ++trie_cnt].left = id;
  }
  trie[now].right = id;
  if (~deep) {
    bool p = num & (1 << deep);
    Insert(num, id, trie[now].son[p], deep - 1);
    PushUp(now);
  } else {
    trie[now].size++;
  }
}
int QueryRank(int num, int top, int now, int deep = LOG_NUM) {
  if (!now) {
    return 0;
  }
  if (~deep) {
    bool p = num & (1 << deep);
    if ((1 << deep) <= top) {
      return QueryRank(num, top - (1 << deep), trie[now].son[p ^ 1], deep - 1);
    } else {
      return trie[trie[now].son[p ^ 1]].size +
             QueryRank(num, top, trie[now].son[p], deep - 1);
    }
  } else {
    return trie[now].size;
  }
}
long long QuerySum(int num, int top, int now, int deep = LOG_NUM) {
  if (!now) {
    return 0;
  }
  if (~deep) {
    bool p = num & (1 << deep);
    if ((1 << deep) <= top) {
      return QuerySum(num, top - (1 << deep), trie[now].son[p ^ 1], deep - 1);
    } else {
      return (GetSum(num, trie[trie[now].son[p ^ 1]].left,
                     trie[trie[now].son[p ^ 1]].right) +
              QuerySum(num, top, trie[now].son[p], deep - 1)) %
             MOD;
    }
  } else {
    return GetSum(num, trie[now].left, trie[now].right);
  }
}
bool Check(int middle) {
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += QueryRank(arr[i], middle, root);
  }
  return k <= sum;
}
int main() {
  Read(n, k);
  k <<= 1;
  for (int i = 1; i <= n; ++i) {
    Read(arr[i]);
  }
  sort(arr + 1, arr + 1 + n);
  for (int i = 1; i <= n; ++i) {
    Insert(arr[i], i, root);
    for (int j = 0; j <= 30; ++j) {
      bit_sum[i][j] = bit_sum[i - 1][j] + (bool)(arr[i] & (1 << j));
    }
  }
  unsigned int left = 0, right = 2e9;
  int middle, kth = 0;
  while (left <= right) {
    if (Check(middle = (left + right) >> 1)) {
      kth = middle;
      left = middle + 1;
    } else {
      right = middle - 1;
    }
  }
  long long answer = 0;
  for (int i = 1; i <= n; ++i) {
    answer += QuerySum(arr[i], kth + 1, root);
    answer %= MOD;
    k -= QueryRank(arr[i], kth + 1, root);
  }
  answer += k * kth % MOD;
  answer = answer % MOD * Pow(2, MOD - 2) % MOD;
  Writeln(answer);
  return 0;
}
