from collections import deque class mf_graph: n=1 g=[[] for i in range(1)] pos=[] def __init__(self,N): self.n=N self.g=[[] for i in range(N)] self.pos=[] def add_edge(self,From,To,cap): assert 0<=From and From0): v=que.popleft() for e in self.g[v]: if e["cap"]==0 or level[e["to"]]>=0:continue level[e["to"]]=level[v]+1 if e["to"]==t:return que.append(e["to"]) def dfs(func,v,up): if (v==s):return up res=0 level_v=level[v] for i in range(Iter[v],len(self.g[v])): e=self.g[v][i] if (level_v<=level[e["to"]] or self.g[e["to"]][e["rev"]]["cap"]==0):continue d=func(func,e["to"],min(up-res,self.g[e["to"]][e["rev"]]["cap"])) if d<=0:continue self.g[v][i]["cap"]+=d self.g[e["to"]][e["rev"]]["cap"]-=d res+=d if res==up:return res level[v]=self.n return res flow=0 while(flow0): p=que.popleft() visited[p]=True for e in self.g[p]: if e["cap"] and not(visited[e["to"]]): visited[e["to"]]=True que.append(e["to"]) return visited #https://qiita.com/zawawahoge/items/8bbd4c2319e7f7746266 def Popcount(x): '''xの立っているビット数をカウントする関数 (xは64bit整数)''' # 2bitごとの組に分け、立っているビット数を2bitで表現する x = x - ((x >> 1) & 0x5555555555555555) # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと x = x + (x >> 8) # 16bitごと x = x + (x >> 16) # 32bitごと x = x + (x >> 32) # 64bitごと = 全部の合計 return x & 0x0000007f N = int(input()) a = list(map(int,input().split())) A = [] sa = N for i in a: for j in range(30): if i ^ (2 ** j) in a: A.append(i) sa -= 1 break N = len(A) from collections import Counter even = Counter() odd = Counter() cntodd = 0 cnteven = 0 for i in range(N): if Popcount(A[i]) % 2 and odd[A[i]] == 0: cntodd += 1 odd[A[i]] = cntodd elif Popcount(A[i]) % 2 == 0 and even[A[i]] == 0: cnteven += 1 even[A[i]] = cnteven n = len(odd.keys()) m = len(even.keys()) G = mf_graph(n + m + 2) l = list(odd.keys()) A = Counter(A) for i in range(n): G.add_edge(0, i + 1, A[l[i]]) l = list(even.keys()) for i in range(m): G.add_edge(n + i + 1, n + m + 1, A[l[i]]) for v1, c1 in odd.items(): for v2, c2 in even.items(): if Popcount(v1 ^ v2) == 1: G.add_edge(c1, n + c2, min(A[v1], A[v2])) f = G.flow(0, n + m + 1) print(N - f + sa)