n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
len = a.max.to_s(2).length
a = a.map { |s| s.to_s(2).rjust(len, '0').reverse }
sum = 0
(0..len-1).each do |i|
  base = 2 ** i
  n = [0, 0]
  a.each do |b|
   n[b[i].to_i] +=1
  end
  sum += base * n[0] * n[1]
end

puts sum % (10 ** 9 + 7)