def Run_Length(lst): run_length=[] if lst: prev=lst[0] cnt=1 for x in lst[1:]: if x==prev: cnt+=1 else: run_length.append((prev,cnt)) prev=x cnt=1 run_length.append((prev,cnt)) return run_length N=int(input()) A=list(map(int,input().split())) ans=0 for b in range(30): cnt=N*(N+1)//2 for a,c in Run_Length([a>>b&1 for a in A]): if a==0: cnt-=c*(c+1)//2 ans+=cnt<