R=range J=lambda:map(int,input().split()) N,K=J() A=sorted(bin(n|1<<30)[3:]for n in J()) M=N*(N-1)>>1 p=[[[0,N],[0,N]]] a=0 def D(v):return v[1]-v[0] for d in R(30): m,q=0,[[],[]] for v in p: s=[] for l,r in v: for i in R(l,r): if A[i][d]>'0':s+=[[[l,i],[i,r]]];break else:s+=[[[l,r],[r,r]]] m+=D(s[0][0])*D(s[1][1])+(v[0]!=v[1])*D(s[1][0])*D(s[0][1]) for e in R(2): for f in R(2): if D(s[0][e])and D(s[1][f])and(v[0]!=v[1]or e<=f):q[e!=f]+=[[s[0][e],s[1][f]]] if M