parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	ct = zeros(Int,60)
	ans = zeros(Int,60)
	for i in 1:n
		for r in 0:59
			if (a[i]>>r)%2 == 0
				ans[60-r] += ct[60-r]
			else
				ans[60-r] += i-1-ct[60-r]
			end
			if (a[i]>>r)%2 == 1
				ct[60-r] += 1
			end
		end
	end
	s = 0
	for r in 0:59
		for i in 1:ans[60-r]
			s = (s+2^r)%mod
		end
	end	
	println(s)
end

main()

