n=int(input()) a=list(map(int,input().split())) def solve(a): l=[0] for v in a: if v: l[-1]+=1 else: l+=[0] c=0 for v in l: c+=(v+1)*v//2 return (n+1)*n//2-c g=0 for i in range(30): g+=solve([(v>>i)&1 for v in a])*(1<