MOD = 10 ** 9 + 7

n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
bit = a.max.to_s(2).length
ans = 0
num1 = Array.new(bit,0)

a.each do |a|
  bit.times do |i|
    num1[i] += a[i]
  end
end

bit.times do |i|
  ans += num1[i] * (n-num1[i]) * (2 ** i)
end

puts ans % MOD
