#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second using ll = long long; using vec = vector; using mat = vector; ll N,M,H,W,Q,K,A,B; string S; typedef pair P; const ll INF = (1LL<<58); ll res(0); using Pint = pair; const int MAX_N = 200005; vec a(MAX_N, 0), sum(MAX_N + 1, 0); vector > bit_sum(18, vector(MAX_N + 1, 0)); void calc1(int l, int r){ res += (sum[r] - sum[l]) * (r - l - 1); rep(i, 18) { ll num = bit_sum[i][r] - bit_sum[i][l]; res -= (1LL<>bit)&1){ calc2({p.fi, p_cen}, {q.fi, q_cen}); calc2({p_cen, p.se}, {q_cen, q.se}); dfs(bit - 1, {p.fi, p_cen}, {q_cen, q.se}); dfs(bit - 1, {p_cen, p.se}, {q.fi, q_cen}); }else{ dfs(bit - 1, {p.fi, p_cen}, {q.fi, q_cen}); dfs(bit - 1, {p_cen, p.se}, {q_cen, q.se}); } } } int main() { cin>>N>>K; rep(i, N) scanf("%d", &a[i]); a.resize(N); sort(ALL(a)); rep(i, N) sum[i+1] = sum[i] + a[i]; rep(i, 18) rep(j, N) bit_sum[i][j+1] = bit_sum[i][j] + ((a[j]>>i)&1); dfs(18, make_pair(0, N), make_pair(N, N)); cout<