n=int(input())
a=list(map(int,input().split()))
v=[0]*64
ans=0
mod=1000000007
zero=0
one=0

index=n-1
while index>=0:
	for k in range(64):
		one=v[k]
		zero=n-1-index-one
		if((a[index]&(1<<k))==0):
			ans=(ans+(1<<k)*one)%mod
		else:
			ans=(ans+(1<<k)*zero)%mod
			v[k]=v[k]+1
	index-=1


print(ans)