def _fourier(f, inverse = False): f = f[:] n = (len(f) - 1).bit_length() for d in range(n): for U in range(1 << n): if not U >> d & 1: s, t = f[U], f[U | 1 << d] f[U], f[U | 1 << d] = s + t, s - t if inverse: for U in range(1 << n): f[U] >>= n return f def convolution(f, g): return _fourier([a * b for a, b in zip(_fourier(f), _fourier(g))], inverse = 1) n, x = map(int, input().split()) A = list(map(int, input().split())) m = max(A).bit_length() f = [0] * (1 << m) g = [0] * (1 << m) for a in A: f[a] += a g[a] += 1 fg = convolution(f, g) ans = 2 * sum(fg[:x]) for d in range(m): f = [0] * (1 << m) for a in A: f[a] += a >> d & 1 f2 = convolution(f, f) ans -= sum(f2[:x]) << d ans -= sum(A) ans //= 2 print(ans)