import random,time def xorconv(n,X,Y): if n==0: res=[(X[0]*Y[0])] return res x=[X[i]+X[i+2**(n-1)] for i in range(2**(n-1))] y=[Y[i]+Y[i+2**(n-1)] for i in range(2**(n-1))] z=[X[i]-X[i+2**(n-1)] for i in range(2**(n-1))] w=[Y[i]-Y[i+2**(n-1)] for i in range(2**(n-1))] res1=xorconv(n-1,x,y) res2=xorconv(n-1,z,w) former=[(res1[i]+res2[i])//2 for i in range(2**(n-1))] latter=[(res1[i]-res2[i])//2 for i in range(2**(n-1))] return former+latter N,X=map(int,input().split()) A=list(map(int,input().split())) def solve_convolute(): data=[0 for i in range(2**18)] for i in range(N): data[A[i]]+=1 data2=xorconv(18,data,data) data2[0]-=N for i in range(2**18): data2[i]//=2 res=0 for i in range(X): res+=i*data2[i] return res print(solve_convolute())